lessPython 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. lessPy/ANOVA.py +70 -11
  2. lessPy/Chart.py +49 -4
  3. lessPy/Correlation.py +39 -10
  4. lessPy/Flows.py +3 -3
  5. lessPy/Logit.py +14 -10
  6. lessPy/Regression.py +22 -18
  7. lessPy/X.py +3 -2
  8. lessPy/XY.py +528 -91
  9. lessPy/bc_items_plotly.py +2 -2
  10. lessPy/bc_plotly.py +6 -5
  11. lessPy/bubble_plotly.py +16 -15
  12. lessPy/corCFA.py +7 -3
  13. lessPy/corProp.py +7 -3
  14. lessPy/corReflect.py +7 -3
  15. lessPy/corReorder.py +7 -3
  16. lessPy/corScree.py +10 -6
  17. lessPy/dn_plotly.py +9 -9
  18. lessPy/dot_plotly.py +9 -8
  19. lessPy/freq_poly_plotly.py +6 -6
  20. lessPy/hier_plotly.py +5 -5
  21. lessPy/hs_plotly.py +7 -7
  22. lessPy/pie_plotly.py +1 -1
  23. lessPy/pivot.py +39 -9
  24. lessPy/plotly_utils.py +90 -26
  25. lessPy/plt_add.py +2 -7
  26. lessPy/plt_contour.py +6 -6
  27. lessPy/plt_contour_facet.py +3 -3
  28. lessPy/plt_mat_plotly.py +11 -10
  29. lessPy/plt_plotly.py +34 -18
  30. lessPy/plt_smooth.py +4 -4
  31. lessPy/prob_norm.py +5 -1
  32. lessPy/prob_tcut.py +5 -1
  33. lessPy/prob_znorm.py +5 -1
  34. lessPy/profile_plotly.py +5 -4
  35. lessPy/radar_plotly.py +4 -3
  36. lessPy/simCImean.py +5 -1
  37. lessPy/simCLT.py +5 -1
  38. lessPy/simFlips.py +5 -1
  39. lessPy/simMeans.py +5 -1
  40. lessPy/style.py +8 -1
  41. lessPy/sunflower_plotly.py +6 -5
  42. lessPy/ttest.py +13 -9
  43. lessPy/utils.py +103 -0
  44. lessPy/vbs_plotly.py +23 -22
  45. {lesspython-0.3.0.dist-info → lesspython-0.3.1.dist-info}/METADATA +8 -1
  46. lesspython-0.3.1.dist-info/RECORD +89 -0
  47. {lesspython-0.3.0.dist-info → lesspython-0.3.1.dist-info}/WHEEL +1 -1
  48. lesspython-0.3.0.dist-info/RECORD +0 -89
  49. {lesspython-0.3.0.dist-info → lesspython-0.3.1.dist-info}/licenses/LICENSE +0 -0
  50. {lesspython-0.3.0.dist-info → lesspython-0.3.1.dist-info}/top_level.txt +0 -0
lessPy/bc_items_plotly.py CHANGED
@@ -196,8 +196,8 @@ def bc_items_plotly(frq, order, fill, labels="%", labels_size=None,
196
196
  xaxis=x_ax, yaxis=y_ax,
197
197
  shapes=(x_grid(axT) if horiz else y_grid(axT)) + plot_border(),
198
198
  legend=leg, template=None,
199
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
200
- paper_bgcolor=to_hex(style_opts["window_fill"]),
199
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
200
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
201
201
  )
202
202
  if main:
203
203
  title_size = round(16 * get_option("main_size", 1))
lessPy/bc_plotly.py CHANGED
@@ -475,8 +475,8 @@ def bc_plotly(x, x_name=None, y_name=None, by_name=None,
475
475
  plt.update_layout(bargroupgap=bargroupgap)
476
476
 
477
477
  plt.update_layout(
478
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
479
- paper_bgcolor=to_hex(style_opts["window_fill"]),
478
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
479
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
480
480
  )
481
481
 
482
482
  if by_name:
@@ -630,9 +630,10 @@ def bc_facet_plotly(x, x_name=None, facet_name=None,
630
630
  legend=dict(title=dict(text=(legend_title
631
631
  if legend_title is not None
632
632
  else by_name),
633
- font=dict(color=to_hex(
633
+ font=dict(color=as_plotly_color(
634
634
  style_opts["lab_color"]))),
635
- font=dict(color=to_hex(style_opts["lab_color"])),
635
+ font=dict(color=as_plotly_color(
636
+ style_opts["lab_color"])),
636
637
  traceorder="normal"))
637
638
  if horiz:
638
639
  fig.update_xaxes(range=[axT1[0], axT1[-1]]) # includes zero
@@ -649,7 +650,7 @@ def bc_facet_plotly(x, x_name=None, facet_name=None,
649
650
  title=dict(text=main, x=0.5, xanchor="center",
650
651
  y=0.99, yanchor="top",
651
652
  font=dict(size=title_size,
652
- color=to_hex(get_option(
653
+ color=as_plotly_color(get_option(
653
654
  "lab_color", "black")))),
654
655
  margin=dict(t=round(title_size * 2.2)))
655
656
  return fig
lessPy/bubble_plotly.py CHANGED
@@ -22,6 +22,7 @@ import plotly.graph_objects as go
22
22
 
23
23
  from .utils import fmt, get_option
24
24
  from .plotly_utils import (
25
+ as_plotly_color,
25
26
  BASE_COLORS, contrast_text_for_hex, facet_layout, make_trans,
26
27
  plotly_style, to_hex,
27
28
  )
@@ -129,7 +130,7 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
129
130
  title=dict(text=main, x=0.5, xanchor="center",
130
131
  y=0.98, yanchor="top",
131
132
  font=dict(size=title_size,
132
- color=to_hex(get_option(
133
+ color=as_plotly_color(get_option(
133
134
  "lab_color", "black")))),
134
135
  margin=dict(t=round(title_size * 2.2),
135
136
  r=25, b=30, l=25))
@@ -166,7 +167,7 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
166
167
 
167
168
  target_r = 0.35
168
169
  y_top = target_r * 1.20
169
- seg_color = to_hex(style_opts["grid_color"])
170
+ seg_color = as_plotly_color(style_opts["grid_color"])
170
171
  hover = (f"{x_name}: %{{customdata.xcat}}"
171
172
  f"<br>{y_name}: %{{hovertext}}"
172
173
  f"<br>% of {x_name}: %{{customdata.pct_x:.1%}}"
@@ -217,7 +218,7 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
217
218
  size=diam_px.tolist(),
218
219
  sizemode="diameter",
219
220
  color=fill_rgba,
220
- line=dict(color=to_hex(border), width=1),
221
+ line=dict(color=as_plotly_color(border), width=1),
221
222
  sizemin=12,
222
223
  ),
223
224
  text=label_show,
@@ -264,8 +265,8 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
264
265
  b=8, l=20, r=20),
265
266
  showlegend=False,
266
267
  template=None,
267
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
268
- paper_bgcolor=to_hex(style_opts["window_fill"]),
268
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
269
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
269
270
  **axes,
270
271
  )
271
272
  if main:
@@ -273,7 +274,7 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
273
274
  text=main, x=0.5, xanchor="center",
274
275
  y=0.98, yanchor="top",
275
276
  font=dict(size=title_size,
276
- color=to_hex(get_option("lab_color",
277
+ color=as_plotly_color(get_option("lab_color",
277
278
  "black")))))
278
279
  return fig
279
280
 
@@ -329,7 +330,7 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
329
330
  size=diam_px.tolist(),
330
331
  sizemode="diameter",
331
332
  color=fill_rgba,
332
- line=dict(color=to_hex(border), width=1),
333
+ line=dict(color=as_plotly_color(border), width=1),
333
334
  sizemin=12,
334
335
  ),
335
336
  text=label_show,
@@ -343,7 +344,7 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
343
344
  target_r = 0.35
344
345
  radius_data = (diam_px / max_diam) * target_r
345
346
  y_top = target_r * 1.20
346
- seg_color = to_hex(style_opts["grid_color"])
347
+ seg_color = as_plotly_color(style_opts["grid_color"])
347
348
  stems = [dict(type="line", xref="x", yref="y",
348
349
  x0=i, x1=i, y0=-1, y1=-float(radius_data[i]),
349
350
  line=dict(color=seg_color, width=1),
@@ -367,8 +368,8 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
367
368
  range=[-1, y_top]),
368
369
  shapes=stems,
369
370
  template=None,
370
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
371
- paper_bgcolor=to_hex(style_opts["window_fill"]),
371
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
372
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
372
373
  )
373
374
  title_layout(fig)
374
375
  return fig
@@ -440,7 +441,7 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
440
441
  size=diam_px.tolist(),
441
442
  sizemode="diameter",
442
443
  color=grp_rgba[i],
443
- line=dict(color=to_hex(border), width=1),
444
+ line=dict(color=as_plotly_color(border), width=1),
444
445
  ),
445
446
  text=label_show,
446
447
  textposition=txt_pos,
@@ -457,7 +458,7 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
457
458
  title=dict(text=x_lab if x_lab is not None else x_name,
458
459
  font=dict(size=lab_font)),
459
460
  showgrid=True,
460
- gridcolor=to_hex(style_opts["grid_color"]),
461
+ gridcolor=as_plotly_color(style_opts["grid_color"]),
461
462
  gridwidth=1,
462
463
  zeroline=False,
463
464
  tickfont=dict(size=tick_font),
@@ -475,11 +476,11 @@ def bubble_plotly(x=None, x_name=None, y_name=None, by_name=None,
475
476
  template=None,
476
477
  shapes=[dict(type="rect", xref="paper", yref="paper",
477
478
  x0=0, x1=1, y0=0, y1=1,
478
- line=dict(color=to_hex(
479
+ line=dict(color=as_plotly_color(
479
480
  style_opts["panel_border"]), width=1),
480
481
  layer="below")],
481
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
482
- paper_bgcolor=to_hex(style_opts["window_fill"]),
482
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
483
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
483
484
  )
484
485
  title_layout(fig)
485
486
  return fig
lessPy/corCFA.py CHANGED
@@ -19,7 +19,7 @@ import re
19
19
  import numpy as np
20
20
  import pandas as pd
21
21
 
22
- from .utils import fmt, get_option, show_plots
22
+ from .utils import fmt, get_option, file_output, show_plots
23
23
 
24
24
 
25
25
  def _mimm(R, cuts, NItems, NF, Iter):
@@ -299,7 +299,7 @@ def _lavaan(fcols, cuts, items):
299
299
 
300
300
  def _cfa_heatmap(Rout, items, fcols):
301
301
  import plotly.graph_objects as go
302
- from .plotly_utils import plotly_style, to_hex
302
+ from .plotly_utils import as_plotly_color, plotly_style, to_hex
303
303
  labels = items + fcols
304
304
  style = plotly_style()
305
305
  fig = go.Figure(go.Heatmap(
@@ -308,9 +308,13 @@ def _cfa_heatmap(Rout, items, fcols):
308
308
  colorbar=dict(title="r")))
309
309
  fig.update_yaxes(autorange="reversed")
310
310
  fig.update_layout(
311
- template=None, paper_bgcolor=to_hex(style["window_fill"]),
311
+ template=None, paper_bgcolor=as_plotly_color(style["window_fill"]),
312
312
  title=dict(text="Item / Factor Correlations", x=0.5,
313
313
  xanchor="center",
314
314
  font=dict(size=round(
315
315
  16 * get_option("main_size", 1)))))
316
316
  return fig
317
+
318
+
319
+ # pdf_file= and png_file= write the figures, as lessR's pdf_file=
320
+ corCFA = file_output(corCFA)
lessPy/corProp.py CHANGED
@@ -11,7 +11,7 @@
11
11
  import numpy as np
12
12
  import pandas as pd
13
13
 
14
- from .utils import get_option, show_plots
14
+ from .utils import get_option, file_output, show_plots
15
15
 
16
16
 
17
17
  def corProp(R, main=None, heat_map=True):
@@ -54,7 +54,7 @@ def corProp(R, main=None, heat_map=True):
54
54
  def _heatmap(df, main):
55
55
  import plotly.graph_objects as go
56
56
 
57
- from .plotly_utils import plotly_style, to_hex
57
+ from .plotly_utils import as_plotly_color, plotly_style, to_hex
58
58
  labels = list(df.columns)
59
59
  Z = df.to_numpy(dtype=float).copy()
60
60
  np.fill_diagonal(Z, np.nan) # ignore the diagonal
@@ -65,9 +65,13 @@ def _heatmap(df, main):
65
65
  colorbar=dict(title="prop")))
66
66
  fig.update_yaxes(autorange="reversed")
67
67
  fig.update_layout(
68
- template=None, paper_bgcolor=to_hex(style["window_fill"]),
68
+ template=None, paper_bgcolor=as_plotly_color(style["window_fill"]),
69
69
  title=dict(text=main or "Item Proportionalities", x=0.5,
70
70
  xanchor="center",
71
71
  font=dict(size=round(
72
72
  16 * get_option("main_size", 1)))))
73
73
  return fig
74
+
75
+
76
+ # pdf_file= and png_file= write the figures, as lessR's pdf_file=
77
+ corProp = file_output(corProp)
lessPy/corReflect.py CHANGED
@@ -11,7 +11,7 @@
11
11
  import numpy as np
12
12
  import pandas as pd
13
13
 
14
- from .utils import get_option, show_plots
14
+ from .utils import get_option, file_output, show_plots
15
15
 
16
16
 
17
17
  def corReflect(R, vars, main=None, heat_map=True):
@@ -53,7 +53,7 @@ def corReflect(R, vars, main=None, heat_map=True):
53
53
  def _heatmap(df, main):
54
54
  import plotly.graph_objects as go
55
55
 
56
- from .plotly_utils import plotly_style, to_hex
56
+ from .plotly_utils import as_plotly_color, plotly_style, to_hex
57
57
  labels = list(df.columns)
58
58
  Z = df.to_numpy(dtype=float).copy()
59
59
  np.fill_diagonal(Z, np.nan)
@@ -64,9 +64,13 @@ def _heatmap(df, main):
64
64
  colorbar=dict(title="r")))
65
65
  fig.update_yaxes(autorange="reversed")
66
66
  fig.update_layout(
67
- template=None, paper_bgcolor=to_hex(style["window_fill"]),
67
+ template=None, paper_bgcolor=as_plotly_color(style["window_fill"]),
68
68
  title=dict(text=main or "With Reflected Item Coefficients",
69
69
  x=0.5, xanchor="center",
70
70
  font=dict(size=round(
71
71
  16 * get_option("main_size", 1)))))
72
72
  return fig
73
+
74
+
75
+ # pdf_file= and png_file= write the figures, as lessR's pdf_file=
76
+ corReflect = file_output(corReflect)
lessPy/corReorder.py CHANGED
@@ -11,7 +11,7 @@
11
11
  import numpy as np
12
12
  import pandas as pd
13
13
 
14
- from .utils import get_option, show_plots
14
+ from .utils import get_option, file_output, show_plots
15
15
 
16
16
  # R hclust method -> scipy linkage method. scipy 'ward' is R's
17
17
  # ward.D2 (squared updates); ward.D has no scipy equivalent, so
@@ -130,7 +130,7 @@ def _apply_diag(M):
130
130
 
131
131
  def _heatmap(df, diagonal_new, main):
132
132
  import plotly.graph_objects as go
133
- from .plotly_utils import plotly_style, to_hex
133
+ from .plotly_utils import as_plotly_color, plotly_style, to_hex
134
134
  Z = df.to_numpy(dtype=float).copy()
135
135
  if diagonal_new:
136
136
  Z = _apply_diag(Z)
@@ -142,7 +142,7 @@ def _heatmap(df, diagonal_new, main):
142
142
  colorbar=dict(title="r")))
143
143
  fig.update_yaxes(autorange="reversed")
144
144
  fig.update_layout(
145
- template=None, paper_bgcolor=to_hex(style["window_fill"]),
145
+ template=None, paper_bgcolor=as_plotly_color(style["window_fill"]),
146
146
  title=dict(text=main or "Reordered Correlations", x=0.5,
147
147
  xanchor="center",
148
148
  font=dict(size=round(
@@ -159,3 +159,7 @@ def _dendrogram(Z, names, label):
159
159
  title=dict(text="Cluster Dendrogram", x=0.5,
160
160
  xanchor="center"))
161
161
  return fig
162
+
163
+
164
+ # pdf_file= and png_file= write the figures, as lessR's pdf_file=
165
+ corReorder = file_output(corReorder)
lessPy/corScree.py CHANGED
@@ -9,9 +9,9 @@ import numpy as np
9
9
  import pandas as pd
10
10
 
11
11
  from .plotly_utils import (
12
- axis_format, axis_num, plot_border, plotly_style, to_hex,
12
+ as_plotly_color, axis_format, axis_num, plot_border, plotly_style, to_hex,
13
13
  x_grid)
14
- from .utils import fmt, get_option, pretty, show_plots
14
+ from .utils import fmt, get_option, pretty, file_output, show_plots
15
15
 
16
16
 
17
17
  class corScreeResults:
@@ -64,7 +64,7 @@ def _scree_plot(y, y_lab, main):
64
64
  import plotly.graph_objects as go
65
65
  style = plotly_style()
66
66
  x = np.arange(1, len(y) + 1)
67
- col = to_hex(get_option("fit_color", "#5C4032"))
67
+ col = as_plotly_color(get_option("fit_color", "#5C4032"))
68
68
  fig = go.Figure(go.Scatter(
69
69
  x=x, y=y, mode="lines+markers",
70
70
  line=dict(color=col, width=1.5),
@@ -74,14 +74,18 @@ def _scree_plot(y, y_lab, main):
74
74
  ax_x = axis_num("Index", list(x), [str(i) for i in x])
75
75
  ax_y = axis_num(y_lab, axT2, axis_format(axT2, 2))
76
76
  ax_y.update(showgrid=True,
77
- gridcolor=to_hex(style["grid_col"]),
77
+ gridcolor=as_plotly_color(style["grid_col"]),
78
78
  gridwidth=1, griddash="dot")
79
79
  fig.update_layout(
80
80
  xaxis=ax_x, yaxis=ax_y,
81
81
  shapes=x_grid(list(x)) + plot_border(), template=None,
82
- plot_bgcolor=to_hex(style["panel_fill"]),
83
- paper_bgcolor=to_hex(style["window_fill"]),
82
+ plot_bgcolor=as_plotly_color(style["panel_fill"]),
83
+ paper_bgcolor=as_plotly_color(style["window_fill"]),
84
84
  title=dict(text=main or "", x=0.5, xanchor="center",
85
85
  font=dict(size=round(
86
86
  16 * get_option("main_size", 1)))))
87
87
  return fig
88
+
89
+
90
+ # pdf_file= and png_file= write the figures, as lessR's pdf_file=
91
+ corScree = file_output(corScree)
lessPy/dn_plotly.py CHANGED
@@ -260,7 +260,7 @@ def dn_plotly(x, by=None, x_name=None, by_name=None,
260
260
  yr += [0.0, y1r, None]
261
261
  fig.add_trace(go.Scatter(
262
262
  mode="lines", x=xr, y=yr,
263
- line=dict(color=to_hex(color_rug),
263
+ line=dict(color=as_plotly_color(color_rug),
264
264
  width=max(0.5, float(size_rug))),
265
265
  hoverinfo="skip", showlegend=False))
266
266
 
@@ -270,12 +270,12 @@ def dn_plotly(x, by=None, x_name=None, by_name=None,
270
270
  axis_shapes = [dict(
271
271
  type="line", xref="paper", yref="paper",
272
272
  x0=0, x1=1, y0=0, y1=0,
273
- line=dict(color=to_hex("gray50"), width=1))]
273
+ line=dict(color=as_plotly_color("gray50"), width=1))]
274
274
 
275
275
  ax_x = axis_num(x_lab, gridT1, gridL1)
276
276
  ax_y = axis_num(y_lab, gridT2, gridL2)
277
277
  ax_y.update(showgrid=True,
278
- gridcolor=to_hex(style_opts["grid_col"]),
278
+ gridcolor=as_plotly_color(style_opts["grid_col"]),
279
279
  gridwidth=1, griddash="dot")
280
280
 
281
281
  fig.update_layout(
@@ -284,8 +284,8 @@ def dn_plotly(x, by=None, x_name=None, by_name=None,
284
284
  shapes=x_grid(gridT1) + plot_border() + axis_shapes,
285
285
  template=None,
286
286
  bargap=0,
287
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
288
- paper_bgcolor=to_hex(style_opts["window_fill"]),
287
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
288
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
289
289
  )
290
290
 
291
291
  if G > 1:
@@ -297,7 +297,7 @@ def dn_plotly(x, by=None, x_name=None, by_name=None,
297
297
  title=dict(text=main, x=0.5, xanchor="center",
298
298
  y=0.99, yanchor="top",
299
299
  font=dict(size=title_size,
300
- color=to_hex(get_option(
300
+ color=as_plotly_color(get_option(
301
301
  "lab_color", "black")))),
302
302
  margin=dict(t=round(title_size * 2.2)))
303
303
  return fig
@@ -475,7 +475,7 @@ def _dn_facet(x, facet, facet_order, x_name, facet_name, fill,
475
475
  else as_plotly_color(fill_normal))
476
476
  fig.add_trace(go.Scatter(
477
477
  mode="lines", x=grid, y=d_nrms[i],
478
- line=dict(color=to_hex(color_normal),
478
+ line=dict(color=as_plotly_color(color_normal),
479
479
  width=1.35 if nrm_fill is None else 1),
480
480
  fill="none" if nrm_fill is None else "tozeroy",
481
481
  fillcolor=nrm_fill,
@@ -489,7 +489,7 @@ def _dn_facet(x, facet, facet_order, x_name, facet_name, fill,
489
489
  yr += [0.0, y1r, None]
490
490
  fig.add_trace(go.Scatter(
491
491
  mode="lines", x=xr, y=yr,
492
- line=dict(color=to_hex(color_rug),
492
+ line=dict(color=as_plotly_color(color_rug),
493
493
  width=max(0.5, float(size_rug))),
494
494
  hoverinfo="skip", showlegend=False,
495
495
  ), row=row, col=p_col)
@@ -509,7 +509,7 @@ def _dn_facet(x, facet, facet_order, x_name, facet_name, fill,
509
509
  title=dict(text=main, x=0.5, xanchor="center",
510
510
  y=0.99, yanchor="top",
511
511
  font=dict(size=title_size,
512
- color=to_hex(get_option(
512
+ color=as_plotly_color(get_option(
513
513
  "lab_color", "black")))),
514
514
  margin=dict(t=round(title_size * 2.2)))
515
515
  return fig
lessPy/dot_plotly.py CHANGED
@@ -19,6 +19,7 @@ import plotly.graph_objects as go
19
19
 
20
20
  from .utils import get_option
21
21
  from .plotly_utils import (
22
+ as_plotly_color,
22
23
  BASE_COLORS, axis_cat, axis_format, axis_num, facet_layout,
23
24
  get_tick_fmt, make_trans, plot_border, plotly_style, to_hex,
24
25
  x_grid, y_grid,
@@ -128,7 +129,7 @@ def _dot_title(main):
128
129
  return dict(text=main, x=0.5, xanchor="center",
129
130
  y=0.98, yanchor="top",
130
131
  font=dict(size=round(16 * get_option("main_size", 1)),
131
- color=to_hex(get_option("lab_color",
132
+ color=as_plotly_color(get_option("lab_color",
132
133
  "black"))))
133
134
 
134
135
 
@@ -169,7 +170,7 @@ def dot_plotly(x, y, orientation="v",
169
170
  else np.asarray(list(vals), dtype=float))
170
171
  flat = flat[np.isfinite(flat)]
171
172
  val_max = float(flat.max()) if flat.size else None
172
- seg_color = to_hex(style_opts["segment_color"])
173
+ seg_color = as_plotly_color(style_opts["segment_color"])
173
174
 
174
175
  def val_ticks(orient):
175
176
  # value-axis labels through the axis_fmt policies ("60K"),
@@ -240,8 +241,8 @@ def dot_plotly(x, y, orientation="v",
240
241
  font=dict(size=round(
241
242
  16 * get_option("axis_size", 0.9)))),
242
243
  template=None,
243
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
244
- paper_bgcolor=to_hex(style_opts["window_fill"]),
244
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
245
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
245
246
  )
246
247
  return fig
247
248
 
@@ -374,8 +375,8 @@ def dot_plotly(x, y, orientation="v",
374
375
  16 * get_option("axis_size", 0.9)))),
375
376
  title=_dot_title(main),
376
377
  template=None,
377
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
378
- paper_bgcolor=to_hex(style_opts["window_fill"]),
378
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
379
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
379
380
  **axes,
380
381
  )
381
382
  return fig
@@ -450,7 +451,7 @@ def dot_plotly(x, y, orientation="v",
450
451
  margin=margin,
451
452
  title=_dot_title(main),
452
453
  template=None,
453
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
454
- paper_bgcolor=to_hex(style_opts["window_fill"]),
454
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
455
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
455
456
  )
456
457
  return fig
@@ -25,7 +25,7 @@ import plotly.graph_objects as go
25
25
 
26
26
  from .utils import get_option, pretty
27
27
  from .plotly_utils import (
28
- auto_opacity, axis_format, axis_num, facet_fig,
28
+ as_plotly_color, auto_opacity, axis_format, axis_num, facet_fig,
29
29
  facet_panels, finish_facet, get_tick_fmt,
30
30
  legend_style, make_trans, plot_border, plotly_style, to_hex,
31
31
  x_grid,
@@ -169,7 +169,7 @@ def freq_poly_plotly(x, by=None, x_name=None, by_name=None,
169
169
  ax_x = axis_num(x_lab, gridT1, gridL1)
170
170
  ax_y = axis_num(y_lab, gridT2, gridL2)
171
171
  ax_y.update(showgrid=True,
172
- gridcolor=to_hex(style_opts["grid_col"]),
172
+ gridcolor=as_plotly_color(style_opts["grid_col"]),
173
173
  gridwidth=1, griddash="dot")
174
174
 
175
175
  fig.update_layout(
@@ -177,8 +177,8 @@ def freq_poly_plotly(x, by=None, x_name=None, by_name=None,
177
177
  yaxis=ax_y,
178
178
  shapes=x_grid(gridT1) + plot_border(),
179
179
  template=None,
180
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
181
- paper_bgcolor=to_hex(style_opts["window_fill"]),
180
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
181
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
182
182
  )
183
183
 
184
184
  if G > 1:
@@ -190,7 +190,7 @@ def freq_poly_plotly(x, by=None, x_name=None, by_name=None,
190
190
  title=dict(text=main, x=0.5, xanchor="center",
191
191
  y=0.99, yanchor="top",
192
192
  font=dict(size=title_size,
193
- color=to_hex(get_option(
193
+ color=as_plotly_color(get_option(
194
194
  "lab_color", "black")))),
195
195
  margin=dict(t=round(title_size * 2.2)))
196
196
  return fig
@@ -325,7 +325,7 @@ def _fp_facet(x, facet, facet_order, x_name, facet_name, breaks,
325
325
  title=dict(text=main, x=0.5, xanchor="center",
326
326
  y=0.99, yanchor="top",
327
327
  font=dict(size=title_size,
328
- color=to_hex(get_option(
328
+ color=as_plotly_color(get_option(
329
329
  "lab_color", "black")))),
330
330
  margin=dict(t=round(title_size * 2.2)))
331
331
  return fig
lessPy/hier_plotly.py CHANGED
@@ -33,7 +33,7 @@ from .getColors import _SEQ_NAMES
33
33
  _HIER_SEQ = set(_SEQ_NAMES) | {"terrain"}
34
34
  from .utils import STAT_FUN, get_option
35
35
  from .plotly_utils import (
36
- BASE_COLORS, facet_layout, plotly_style, to_hex,
36
+ as_plotly_color, BASE_COLORS, facet_layout, plotly_style, to_hex,
37
37
  )
38
38
 
39
39
  _LABEL_VALUES = ("input", "%", "prop", "off")
@@ -233,7 +233,7 @@ def hier_plotly(agg, fill_vec, type="sunburst", fill_vec_byfac=None,
233
233
 
234
234
  title_size = round(16 * get_option("main_size", 1))
235
235
  label_fsize = 18 * labels_size * get_option("axis_size", 0.9)
236
- border_hex = to_hex("white" if border is None else border)
236
+ border_hex = as_plotly_color("white" if border is None else border)
237
237
 
238
238
  digits = 2 if digits_d is None else max(0, int(digits_d))
239
239
  if non_additive and digits == 0:
@@ -298,7 +298,7 @@ def hier_plotly(agg, fill_vec, type="sunburst", fill_vec_byfac=None,
298
298
  **kw,
299
299
  )
300
300
 
301
- lab_color = to_hex(get_option("lab_color", "black"))
301
+ lab_color = as_plotly_color(get_option("lab_color", "black"))
302
302
 
303
303
  # ---- faceted grid: one panel per facet level -------------------
304
304
  # R analog: hier.plotly.R faceted section
@@ -378,7 +378,7 @@ def hier_plotly(agg, fill_vec, type="sunburst", fill_vec_byfac=None,
378
378
  x=0.55 if type == "icicle" else 0.50,
379
379
  xanchor="center"),
380
380
  template=None,
381
- paper_bgcolor=to_hex(style_opts["window_fill"]),
381
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
382
382
  )
383
383
  return fig
384
384
 
@@ -417,6 +417,6 @@ def hier_plotly(agg, fill_vec, type="sunburst", fill_vec_byfac=None,
417
417
 
418
418
  fig.update_layout(
419
419
  template=None,
420
- paper_bgcolor=to_hex(style_opts["window_fill"]),
420
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
421
421
  )
422
422
  return fig
lessPy/hs_plotly.py CHANGED
@@ -24,7 +24,7 @@ import plotly.graph_objects as go
24
24
 
25
25
  from .utils import get_option, pretty
26
26
  from .plotly_utils import (
27
- auto_opacity, axis_format, axis_num, facet_fig,
27
+ as_plotly_color, auto_opacity, axis_format, axis_num, facet_fig,
28
28
  facet_panels, finish_facet, get_tick_fmt,
29
29
  legend_style, make_trans, plot_border, plotly_style, to_hex,
30
30
  x_grid,
@@ -190,7 +190,7 @@ def hs_plotly(x, by=None, x_name=None, by_name=None,
190
190
  extra = dict(
191
191
  text=[f"{round(v, digits_d):g}" for v in yv],
192
192
  textposition="outside", cliponaxis=False,
193
- textfont=dict(color=to_hex(get_option(
193
+ textfont=dict(color=as_plotly_color(get_option(
194
194
  "lab_color", "black"))))
195
195
  fig.add_trace(go.Bar(
196
196
  x=mids,
@@ -236,7 +236,7 @@ def hs_plotly(x, by=None, x_name=None, by_name=None,
236
236
  ax_x = axis_num(x_lab, ax["axT1"], ax["axL1"])
237
237
  ax_y = axis_num(y_lab, ax["axT2"], ax["axL2"])
238
238
  ax_y.update(showgrid=True,
239
- gridcolor=to_hex(style_opts["grid_col"]),
239
+ gridcolor=as_plotly_color(style_opts["grid_col"]),
240
240
  gridwidth=1, griddash="dot")
241
241
 
242
242
  fig.update_layout(
@@ -247,8 +247,8 @@ def hs_plotly(x, by=None, x_name=None, by_name=None,
247
247
  barmode=("stack" if (G > 1 and position == "stack")
248
248
  else "overlay"),
249
249
  bargap=0,
250
- plot_bgcolor=to_hex(style_opts["panel_fill"]),
251
- paper_bgcolor=to_hex(style_opts["window_fill"]),
250
+ plot_bgcolor=as_plotly_color(style_opts["panel_fill"]),
251
+ paper_bgcolor=as_plotly_color(style_opts["window_fill"]),
252
252
  )
253
253
 
254
254
  if G > 1:
@@ -260,7 +260,7 @@ def hs_plotly(x, by=None, x_name=None, by_name=None,
260
260
  title=dict(text=main, x=0.5, xanchor="center",
261
261
  y=0.99, yanchor="top",
262
262
  font=dict(size=title_size,
263
- color=to_hex(get_option(
263
+ color=as_plotly_color(get_option(
264
264
  "lab_color", "black")))),
265
265
  margin=dict(t=round(title_size * 2.2)))
266
266
  return fig
@@ -401,7 +401,7 @@ def _hs_facet(x, facet, facet_order, x_name, facet_name, breaks,
401
401
  title=dict(text=main, x=0.5, xanchor="center",
402
402
  y=0.99, yanchor="top",
403
403
  font=dict(size=title_size,
404
- color=to_hex(get_option(
404
+ color=as_plotly_color(get_option(
405
405
  "lab_color", "black")))),
406
406
  margin=dict(t=round(title_size * 2.2)))
407
407
  return fig
lessPy/pie_plotly.py CHANGED
@@ -135,7 +135,7 @@ def pie_plotly(x, x_name=None, y_name=None, by_name=None, main=None,
135
135
  return dict(text=main, y=0.94, yanchor="top",
136
136
  font=dict(
137
137
  size=title_size,
138
- color=to_hex(get_option("lab_color",
138
+ color=as_plotly_color(get_option("lab_color",
139
139
  "black"))))
140
140
  return None
141
141