py2ls 0.1.8.0__py3-none-any.whl → 0.1.8.2__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():
@@ -976,8 +978,13 @@ def figsets(*args, **kwargs):
976
978
  from cycler import cycler
977
979
 
978
980
 
979
- # set up the colorlist, give the number, or the colormap's name
980
- def get_color(n=1, cmap="auto", by="start"):
981
+ def get_color(
982
+ n: int = 1,
983
+ cmap: str = "auto",
984
+ by: str = "start",
985
+ alpha: float = 1.0,
986
+ output: str = "rgb",
987
+ ):
981
988
  # Extract the colormap as a list
982
989
  def cmap2hex(cmap_name):
983
990
  cmap_ = matplotlib.pyplot.get_cmap(cmap_name)
@@ -985,7 +992,7 @@ def get_color(n=1, cmap="auto", by="start"):
985
992
  return [matplotlib.colors.rgb2hex(color) for color in colors]
986
993
  # usage: clist = cmap2hex("viridis")
987
994
 
988
- # cycle times, total number is n (defaultn=10)
995
+ # Cycle times, total number is n (default n=10)
989
996
  def cycle2list(colorlist, n=10):
990
997
  cycler_ = cycler(tmp=colorlist)
991
998
  clist = []
@@ -995,20 +1002,23 @@ def get_color(n=1, cmap="auto", by="start"):
995
1002
  break
996
1003
  return clist
997
1004
 
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("#"):
1005
+ # Converts hexadecimal color codes to RGBA values
1006
+ def hue2rgb(hex_colors, alpha=1.0):
1007
+ def hex_to_rgba(hex_color, alpha=1.0):
1008
+ """Converts a hexadecimal color code to RGBA values."""
1009
+ if hex_color.startswith("#"):
1002
1010
  hex_color = hex_color.lstrip("#")
1003
- return tuple(int(hex_color[i : i + 2], 16) / 255.0 for i in (0, 2, 4))
1011
+ rgb = tuple(int(hex_color[i : i + 2], 16) / 255.0 for i in (0, 2, 4))
1012
+ return rgb + (alpha,)
1004
1013
 
1005
1014
  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
1015
+ return hex_to_rgba(hex_colors, alpha)
1016
+ elif isinstance(hex_colors, list):
1017
+ """Converts a list of hexadecimal color codes to a list of RGBA values."""
1018
+ rgba_values = [hex_to_rgba(hex_color, alpha) for hex_color in hex_colors]
1019
+ return rgba_values
1011
1020
 
1021
+ # Determine color list based on cmap parameter
1012
1022
  if "aut" in cmap:
1013
1023
  colorlist = [
1014
1024
  "#474747",
@@ -1021,8 +1031,9 @@ def get_color(n=1, cmap="auto", by="start"):
1021
1031
  ]
1022
1032
  else:
1023
1033
  colorlist = cmap2hex(cmap)
1034
+
1035
+ # Determine method for generating color list
1024
1036
  if "st" in by.lower() or "be" in by.lower():
1025
- # cycle it
1026
1037
  clist = cycle2list(colorlist, n=n)
1027
1038
  if "l" in by.lower() or "p" in by.lower():
1028
1039
  clist = []
@@ -1031,8 +1042,16 @@ def get_color(n=1, cmap="auto", by="start"):
1031
1042
  for i in [int(i) for i in np.linspace(0, len(colorlist) - 1, n)]
1032
1043
  ]
1033
1044
 
1034
- return clist # a color list
1035
- # example usage: clist = get_color(4,cmap="auto", by="start") # get_color(4, cmap="hot", by="linspace")
1045
+ if output == "rgb":
1046
+ return hue2rgb(clist, alpha)
1047
+ elif output == "hue":
1048
+ return clist
1049
+ else:
1050
+ raise ValueError("Invalid output type. Choose 'rgb' or 'hue'.")
1051
+
1052
+ # # Example usage
1053
+ # colors = get_color(n=5, cmap="viridis", by="linear", alpha=0.5)
1054
+ # print(colors)
1036
1055
 
1037
1056
 
1038
1057
  """
@@ -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.2
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=nGGA9Xqa5MzU5X7aE7Mfkk0qrnOkn3DGYulKuh-Ew48,100571
138
138
  py2ls/netfinder.py,sha256=MY_0TQY_zaRBZ6wfR4RxNCGrU93HFmDVDRRy1EXl75o,47566
139
- py2ls/plot.py,sha256=iCbLxxQNAswBI3jEYDwjVF_gl3npI4AVskgezs0bjvQ,49322
139
+ py2ls/plot.py,sha256=2SVycCCPQG_N7Z6dYDCCMBXDyddogbpIu0SkjXJNI5M,49877
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.2.dist-info/METADATA,sha256=ZnmByp2nveooGWTwA9izvfzp7U-KgLT7vsaEtU9LteY,20017
146
+ py2ls-0.1.8.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
147
+ py2ls-0.1.8.2.dist-info/RECORD,,