py2ls 0.1.8.0__py3-none-any.whl → 0.1.8.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.
py2ls/plot.py CHANGED
@@ -17,7 +17,7 @@ def catplot(data, *args, **kwargs):
17
17
  data (array): data matrix
18
18
  """
19
19
 
20
- def plot_bars(data_m, opt_b, xloc, ax):
20
+ def plot_bars(data, data_m, opt_b, xloc, ax):
21
21
  bar_positions = get_positions(
22
22
  xloc, opt_b["loc"], opt_b["x_width"], data.shape[0]
23
23
  )
@@ -344,8 +344,6 @@ def catplot(data, *args, **kwargs):
344
344
  np.linspace(0, 1, data.shape[1] - len(opt["c"]))
345
345
  )
346
346
  opt["c"] = np.vstack([opt["c"], additional_colors[:, :3]])
347
- if isinstance(opt["c"], dict):
348
- opt["c"] = opt["c"]["c"]
349
347
 
350
348
  opt.setdefault("loc", {})
351
349
  opt["loc"].setdefault("go", 0)
@@ -476,7 +474,7 @@ def catplot(data, *args, **kwargs):
476
474
  layers = sort_catplot_layers(opt["layer"])
477
475
  for layer in layers:
478
476
  if layer == "b" and opt["b"]["go"]:
479
- plot_bars(data_m, opt["b"], xloc, ax)
477
+ plot_bars(data, data_m, opt["b"], xloc, ax)
480
478
  elif layer == "e" and opt["e"]["go"]:
481
479
  plot_errors(data, data_m, opt["e"], xloc, ax)
482
480
  elif layer == "s" and opt["s"]["go"]:
@@ -642,7 +640,7 @@ def figsets(*args, **kwargs):
642
640
  box=['right','bottom'],
643
641
  xrot=-45,
644
642
  yangle=20,
645
- font_sz = 2,
643
+ font_sz = 12,
646
644
  legend=dict(labels=['group_a','group_b'],
647
645
  loc='upper left',
648
646
  edgecolor='k',
@@ -685,7 +683,8 @@ def figsets(*args, **kwargs):
685
683
  def set_step_1(ax, key, value):
686
684
  if ("fo" in key) and (("size" in key) or ("sz" in key)):
687
685
  fontsize = value
688
- plt.rcParams.update({"font.size": value})
686
+ print(fontsize)
687
+ plt.rcParams.update({"font.size": fontsize})
689
688
  # style
690
689
  if "st" in key.lower() or "th" in key.lower():
691
690
  if isinstance(value, str):
@@ -786,15 +785,18 @@ def figsets(*args, **kwargs):
786
785
  # rotation
787
786
  if "angle" in key.lower() or ("rot" in key.lower()):
788
787
  if "x" in key.lower():
789
- ax.tick_params(axis="x", rotation=value)
790
- for tick in ax.get_xticklabels():
791
- if value in [0, 90, 180, 270]:
788
+ if value in [0, 90, 180, 270]:
789
+ ax.tick_params(axis="x", rotation=value)
790
+ for tick in ax.get_xticklabels():
792
791
  tick.set_horizontalalignment("center")
793
- else:
794
- if value > 0:
795
- tick.set_horizontalalignment("right")
796
- elif value < 0:
797
- tick.set_horizontalalignment("left")
792
+ elif value > 0:
793
+ ax.tick_params(axis="x", rotation=value)
794
+ for tick in ax.get_xticklabels():
795
+ tick.set_horizontalalignment("right")
796
+ elif value < 0:
797
+ ax.tick_params(axis="x", rotation=value)
798
+ for tick in ax.get_xticklabels():
799
+ tick.set_horizontalalignment("left")
798
800
  if "y" in key.lower():
799
801
  ax.tick_params(axis="y", rotation=value)
800
802
  for tick in ax.get_yticklabels():
@@ -977,7 +979,7 @@ from cycler import cycler
977
979
 
978
980
 
979
981
  # set up the colorlist, give the number, or the colormap's name
980
- def get_color(n=1, cmap="auto", by="start"):
982
+ def get_color(n=1, cmap="auto", by="start", alpha=1.0):
981
983
  # Extract the colormap as a list
982
984
  def cmap2hex(cmap_name):
983
985
  cmap_ = matplotlib.pyplot.get_cmap(cmap_name)
@@ -985,7 +987,7 @@ def get_color(n=1, cmap="auto", by="start"):
985
987
  return [matplotlib.colors.rgb2hex(color) for color in colors]
986
988
  # usage: clist = cmap2hex("viridis")
987
989
 
988
- # cycle times, total number is n (defaultn=10)
990
+ # Cycle times, total number is n (default n=10)
989
991
  def cycle2list(colorlist, n=10):
990
992
  cycler_ = cycler(tmp=colorlist)
991
993
  clist = []
@@ -995,20 +997,23 @@ def get_color(n=1, cmap="auto", by="start"):
995
997
  break
996
998
  return clist
997
999
 
998
- def hue2rgb(hex_colors):
999
- def hex_to_rgb(hex_color):
1000
- """Converts a hexadecimal color code to RGB values."""
1001
- if hex_colors.startswith("#"):
1000
+ # Converts hexadecimal color codes to RGBA values
1001
+ def hue2rgb(hex_colors, alpha=1.0):
1002
+ def hex_to_rgba(hex_color, alpha=1.0):
1003
+ """Converts a hexadecimal color code to RGBA values."""
1004
+ if hex_color.startswith("#"):
1002
1005
  hex_color = hex_color.lstrip("#")
1003
- return tuple(int(hex_color[i : i + 2], 16) / 255.0 for i in (0, 2, 4))
1006
+ rgb = tuple(int(hex_color[i : i + 2], 16) / 255.0 for i in (0, 2, 4))
1007
+ return rgb + (alpha,)
1004
1008
 
1005
1009
  if isinstance(hex_colors, str):
1006
- return hex_to_rgb(hex_colors)
1007
- elif isinstance(hex_colors, (list)):
1008
- """Converts a list of hexadecimal color codes to a list of RGB values."""
1009
- rgb_values = [hex_to_rgb(hex_color) for hex_color in hex_colors]
1010
- return rgb_values
1010
+ return hex_to_rgba(hex_colors, alpha)
1011
+ elif isinstance(hex_colors, list):
1012
+ """Converts a list of hexadecimal color codes to a list of RGBA values."""
1013
+ rgba_values = [hex_to_rgba(hex_color, alpha) for hex_color in hex_colors]
1014
+ return rgba_values
1011
1015
 
1016
+ # Determine color list based on cmap parameter
1012
1017
  if "aut" in cmap:
1013
1018
  colorlist = [
1014
1019
  "#474747",
@@ -1021,8 +1026,9 @@ def get_color(n=1, cmap="auto", by="start"):
1021
1026
  ]
1022
1027
  else:
1023
1028
  colorlist = cmap2hex(cmap)
1029
+
1030
+ # Determine method for generating color list
1024
1031
  if "st" in by.lower() or "be" in by.lower():
1025
- # cycle it
1026
1032
  clist = cycle2list(colorlist, n=n)
1027
1033
  if "l" in by.lower() or "p" in by.lower():
1028
1034
  clist = []
@@ -1031,8 +1037,14 @@ def get_color(n=1, cmap="auto", by="start"):
1031
1037
  for i in [int(i) for i in np.linspace(0, len(colorlist) - 1, n)]
1032
1038
  ]
1033
1039
 
1034
- return clist # a color list
1035
- # example usage: clist = get_color(4,cmap="auto", by="start") # get_color(4, cmap="hot", by="linspace")
1040
+ # Convert colors to RGBA format with the specified alpha
1041
+ clist_with_alpha = hue2rgb(clist, alpha)
1042
+
1043
+ return clist_with_alpha
1044
+
1045
+ # # Example usage
1046
+ # colors = get_color(n=5, cmap="viridis", by="linear", alpha=0.5)
1047
+ # print(colors)
1036
1048
 
1037
1049
 
1038
1050
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2ls
3
- Version: 0.1.8.0
3
+ Version: 0.1.8.1
4
4
  Summary: py(thon)2(too)ls
5
5
  Author: Jianfeng
6
6
  Author-email: Jianfeng.Liu0413@gmail.com
@@ -134,14 +134,14 @@ py2ls/db2ls.py,sha256=MMfFX47aIPIyu7fU9aPvX9lbPRPYOpJ_VXwlnWk-8qo,13615
134
134
  py2ls/doc.py,sha256=xN3g1OWfoaGUhikbJ0NqbN5eKy1VZVvWwRlhHMgyVEc,4243
135
135
  py2ls/export_requirements.py,sha256=x2WgUF0jYKz9GfA1MVKN-MdsM-oQ8yUeC6Ua8oCymio,2325
136
136
  py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
137
- py2ls/ips.py,sha256=KkrkGAF0VQ-N0rH4FQFLyP-C-skY6EPpeO8t_5RngWw,88519
137
+ py2ls/ips.py,sha256=w3FfvnCnsl92XHm3sxzGpr2LhUZ7zUNgvrS9WSaquYo,102629
138
138
  py2ls/netfinder.py,sha256=MY_0TQY_zaRBZ6wfR4RxNCGrU93HFmDVDRRy1EXl75o,47566
139
- py2ls/plot.py,sha256=iCbLxxQNAswBI3jEYDwjVF_gl3npI4AVskgezs0bjvQ,49322
139
+ py2ls/plot.py,sha256=Y9tmGlIN4jjVKRtPpRDz067yq0DlR9KYv5TJ7s3jZwc,49812
140
140
  py2ls/setuptools-70.1.0-py3-none-any.whl,sha256=2bi3cUVal8ip86s0SOvgspteEF8SKLukECi-EWmFomc,882588
141
141
  py2ls/sleep_events_detectors.py,sha256=bQA3HJqv5qnYKJJEIhCyhlDtkXQfIzqksnD0YRXso68,52145
142
142
  py2ls/stats.py,sha256=Wd9yCKQ_61QD29WMEgMuEcreFxF91NmlPW65iWT2B5w,39041
143
143
  py2ls/translator.py,sha256=bc5FB-wqC4TtQz9gyCP1mE38HqNRJ_pmuRIgKnAlMzM,30581
144
144
  py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
145
- py2ls-0.1.8.0.dist-info/METADATA,sha256=LHHeX9JGLb7F_vomtiA9FB9QAwcyan7L_pspKLUN7L8,20017
146
- py2ls-0.1.8.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
147
- py2ls-0.1.8.0.dist-info/RECORD,,
145
+ py2ls-0.1.8.1.dist-info/METADATA,sha256=aG7rHa3yELrjuHiV338xDPIxbCEgCssNxY8CepQTSOw,20017
146
+ py2ls-0.1.8.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
147
+ py2ls-0.1.8.1.dist-info/RECORD,,