py2ls 0.1.6.0__py3-none-any.whl → 0.1.6.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/figsets.py ADDED
@@ -0,0 +1,372 @@
1
+
2
+ import numpy as np
3
+ import matplotlib
4
+ import matplotlib.pyplot as plt
5
+ import matplotlib.ticker as tck
6
+ import seaborn as sns
7
+ from cycler import cycler
8
+
9
+
10
+ def get_cmap():
11
+ return plt.colormaps()
12
+
13
+ def read_mplstyle(style_file):
14
+ # Load the style file
15
+ plt.style.use(style_file)
16
+
17
+ # Get the current style properties
18
+ style_dict = plt.rcParams
19
+
20
+ # Convert to dictionary
21
+ style_dict = dict(style_dict)
22
+ # Print the style dictionary
23
+ for i, j in style_dict.items():
24
+ print(f"\n{i}::::{j}")
25
+ return style_dict
26
+ # #example usage:
27
+ # style_file = "/ std-colors.mplstyle"
28
+ # style_dict = read_mplstyle(style_file)
29
+
30
+ def figsets(*args,**kwargs):
31
+ """
32
+ usage:
33
+ figsets(ax=axs[1],
34
+ ylim=[0, 10],
35
+ spine=2,
36
+ xticklabel=['wake','sleep'],
37
+ yticksdddd=np.arange(0,316,60),
38
+ labels_loc=['right','top'],
39
+ ticks=dict(
40
+ ax='x',
41
+ which='minor',
42
+ direction='out',
43
+ width=2,
44
+ length=2,
45
+ c_tick='m',
46
+ pad=5,
47
+ label_size=11),
48
+ grid=dict(which='minor',
49
+ ax='x',
50
+ alpha=.4,
51
+ c='b',
52
+ ls='-.',
53
+ lw=0.75,
54
+ ),
55
+ supertitleddddd=f'sleep druations\n(min)',
56
+ c_spine='r',
57
+ minor_ticks='xy',
58
+ style='paper',
59
+ box=['right','bottom'],
60
+ xrot=-45,
61
+ yangle=20,
62
+ font_sz = 2,
63
+ legend=dict(labels=['group_a','group_b'],
64
+ loc='upper left',
65
+ edgecolor='k',
66
+ facecolor='r',
67
+ title='title',
68
+ fancybox=1,
69
+ shadow=1,
70
+ ncols=4,
71
+ bbox_to_anchor=[-0.5,0.7],
72
+ alignment='left')
73
+ )
74
+ """
75
+ fig = plt.gcf()
76
+ fontsize = 11
77
+ fontname = "Arial"
78
+ sns_themes = ["white", "whitegrid", "dark", "darkgrid", "ticks"]
79
+ sns_contexts = ["notebook", "talk", "poster"] # now available "paper"
80
+ scienceplots_styles = ["science","nature",
81
+ "scatter","ieee","no-latex","std-colors","high-vis","bright","dark_background","science",
82
+ "high-vis","vibrant","muted","retro","grid","high-contrast","light","cjk-tc-font","cjk-kr-font",
83
+ ]
84
+ def set_step_1(ax,key, value):
85
+ if ("fo" in key) and (("size" in key) or ("sz" in key)):
86
+ fontsize=value
87
+ plt.rcParams.update({"font.size": value})
88
+ # style
89
+ if "st" in key.lower() or "th" in key.lower():
90
+ if isinstance(value, str):
91
+ if (value in plt.style.available) or (value in scienceplots_styles):
92
+ plt.style.use(value)
93
+ elif value in sns_themes:
94
+ sns.set_style(value)
95
+ elif value in sns_contexts:
96
+ sns.set_context(value)
97
+ else:
98
+ print(
99
+ f"\nWarning\n'{value}' is not a plt.style,select on below:\n{plt.style.available+sns_themes+sns_contexts+scienceplots_styles}"
100
+ )
101
+ if isinstance(value, list):
102
+ for i in value:
103
+ if (i in plt.style.available) or (i in scienceplots_styles):
104
+ plt.style.use(i)
105
+ elif i in sns_themes:
106
+ sns.set_style(i)
107
+ elif i in sns_contexts:
108
+ sns.set_context(i)
109
+ else:
110
+ print(
111
+ f"\nWarning\n'{i}' is not a plt.style,select on below:\n{plt.style.available+sns_themes+sns_contexts+scienceplots_styles}"
112
+ )
113
+ if "la" in key.lower():
114
+ if "loc" in key.lower() or "po" in key.lower():
115
+ for i in value:
116
+ if "l" in i.lower() and not 'g' in i.lower():
117
+ ax.yaxis.set_label_position("left")
118
+ if "r" in i.lower() and not 'o' in i.lower():
119
+ ax.yaxis.set_label_position("right")
120
+ if "t" in i.lower() and not 'l' in i.lower():
121
+ ax.xaxis.set_label_position("top")
122
+ if "b" in i.lower()and not 'o' in i.lower():
123
+ ax.xaxis.set_label_position("bottom")
124
+ if ("x" in key.lower()) and (
125
+ "tic" not in key.lower() and "tk" not in key.lower()
126
+ ):
127
+ ax.set_xlabel(value, fontname=fontname)
128
+ if ("y" in key.lower()) and (
129
+ "tic" not in key.lower() and "tk" not in key.lower()
130
+ ):
131
+ ax.set_ylabel(value, fontname=fontname)
132
+ if ("z" in key.lower()) and (
133
+ "tic" not in key.lower() and "tk" not in key.lower()
134
+ ):
135
+ ax.set_zlabel(value, fontname=fontname)
136
+ if key=='xlabel' and isinstance(value,dict):
137
+ ax.set_xlabel(**value)
138
+ if key=='ylabel' and isinstance(value,dict):
139
+ ax.set_ylabel(**value)
140
+ # tick location
141
+ if "tic" in key.lower() or "tk" in key.lower():
142
+ if ("loc" in key.lower()) or ("po" in key.lower()):
143
+ if isinstance(value,str):
144
+ value=[value]
145
+ if isinstance(value, list):
146
+ loc = []
147
+ for i in value:
148
+ if ("l" in i.lower()) and ("a" not in i.lower()):
149
+ ax.yaxis.set_ticks_position("left")
150
+ if "r" in i.lower():
151
+ ax.yaxis.set_ticks_position("right")
152
+ if "t" in i.lower():
153
+ ax.xaxis.set_ticks_position("top")
154
+ if "b" in i.lower():
155
+ ax.xaxis.set_ticks_position("bottom")
156
+ if i.lower() in ["a", "both", "all", "al", ":"]:
157
+ ax.xaxis.set_ticks_position("both")
158
+ ax.yaxis.set_ticks_position("both")
159
+ if i.lower() in ["xnone",'xoff',"none"]:
160
+ ax.xaxis.set_ticks_position("none")
161
+ if i.lower() in ["ynone",'yoff','none']:
162
+ ax.yaxis.set_ticks_position("none")
163
+ # ticks / labels
164
+ elif "x" in key.lower():
165
+ if value is None:
166
+ value=[]
167
+ if "la" not in key.lower():
168
+ ax.set_xticks(value)
169
+ if "la" in key.lower():
170
+ ax.set_xticklabels(value)
171
+ elif "y" in key.lower():
172
+ if value is None:
173
+ value=[]
174
+ if "la" not in key.lower():
175
+ ax.set_yticks(value)
176
+ if "la" in key.lower():
177
+ ax.set_yticklabels(value)
178
+ elif "z" in key.lower():
179
+ if value is None:
180
+ value=[]
181
+ if "la" not in key.lower():
182
+ ax.set_zticks(value)
183
+ if "la" in key.lower():
184
+ ax.set_zticklabels(value)
185
+ # rotation
186
+ if "angle" in key.lower() or ("rot" in key.lower()):
187
+ if "x" in key.lower():
188
+ if value in [0,90,180,270]:
189
+ ax.tick_params(axis="x", rotation=value)
190
+ for tick in ax.get_xticklabels():
191
+ tick.set_horizontalalignment('center')
192
+ elif value >0:
193
+ ax.tick_params(axis="x", rotation=value)
194
+ for tick in ax.get_xticklabels():
195
+ tick.set_horizontalalignment('right')
196
+ elif value <0:
197
+ ax.tick_params(axis='x', rotation=value)
198
+ for tick in ax.get_xticklabels():
199
+ tick.set_horizontalalignment('left')
200
+ if "y" in key.lower():
201
+ ax.tick_params(axis="y", rotation=value)
202
+ for tick in ax.get_yticklabels():
203
+ tick.set_horizontalalignment('right')
204
+
205
+ if "bo" in key in key: # box setting, and ("p" in key or "l" in key):
206
+ if isinstance(value, (str, list)):
207
+ locations = []
208
+ for i in value:
209
+ if "l" in i.lower() and not 't' in i.lower():
210
+ locations.append("left")
211
+ if "r" in i.lower()and not 'o' in i.lower(): # right
212
+ locations.append("right")
213
+ if "t" in i.lower() and not 'r' in i.lower(): #top
214
+ locations.append("top")
215
+ if "b" in i.lower() and not 't' in i.lower():
216
+ locations.append("bottom")
217
+ if i.lower() in ["a", "both", "all", "al", ":"]:
218
+ [
219
+ locations.append(x)
220
+ for x in ["left", "right", "top", "bottom"]
221
+ ]
222
+ for i in value:
223
+ if i.lower() in "none":
224
+ locations = []
225
+ # check spines
226
+ for loc, spi in ax.spines.items():
227
+ if loc in locations:
228
+ spi.set_position(("outward", 0))
229
+ else:
230
+ spi.set_color("none") # no spine
231
+ if 'tick' in key.lower(): # tick ticks tick_para ={}
232
+ if isinstance(value, dict):
233
+ for k, val in value.items():
234
+ if "wh" in k.lower():
235
+ ax.tick_params(
236
+ which=val
237
+ ) # {'major', 'minor', 'both'}, default: 'major'
238
+ elif "dir" in k.lower():
239
+ ax.tick_params(direction=val) # {'in', 'out', 'inout'}
240
+ elif "len" in k.lower():# length
241
+ ax.tick_params(length=val)
242
+ elif ("wid" in k.lower()) or ("wd" in k.lower()): # width
243
+ ax.tick_params(width=val)
244
+ elif "ax" in k.lower(): # ax
245
+ ax.tick_params(axis=val) # {'x', 'y', 'both'}, default: 'both'
246
+ elif ("c" in k.lower()) and ("ect" not in k.lower()):
247
+ ax.tick_params(colors=val) # Tick color.
248
+ elif "pad" in k.lower() or 'space' in k.lower():
249
+ ax.tick_params(
250
+ pad=val
251
+ ) # float, distance in points between tick and label
252
+ elif (
253
+ ("lab" in k.lower() or 'text' in k.lower())
254
+ and ("s" in k.lower())
255
+ and ("z" in k.lower())
256
+ ): # label_size
257
+ ax.tick_params(
258
+ labelsize=val
259
+ ) # float, distance in points between tick and label
260
+
261
+ if "mi" in key.lower() and "tic" in key.lower():# minor_ticks
262
+ if "x" in value.lower() or "x" in key.lower():
263
+ ax.xaxis.set_minor_locator(tck.AutoMinorLocator()) # ax.minorticks_on()
264
+ if "y" in value.lower() or "y" in key.lower():
265
+ ax.yaxis.set_minor_locator(
266
+ tck.AutoMinorLocator()
267
+ ) # ax.minorticks_off()
268
+ if value.lower() in ["both", ":", "all", "a", "b", "on"]:
269
+ ax.minorticks_on()
270
+ if key == "colormap" or key == "cmap":
271
+ plt.set_cmap(value)
272
+ def set_step_2(ax,key, value):
273
+ if key == "figsize":
274
+ pass
275
+ if "xlim" in key.lower():
276
+ ax.set_xlim(value)
277
+ if "ylim" in key.lower():
278
+ ax.set_ylim(value)
279
+ if "zlim" in key.lower():
280
+ ax.set_zlim(value)
281
+ if "sc" in key.lower(): #scale
282
+ if "x" in key.lower():
283
+ ax.set_xscale(value)
284
+ if "y" in key.lower():
285
+ ax.set_yscale(value)
286
+ if "z" in key.lower():
287
+ ax.set_zscale(value)
288
+ if key == "grid":
289
+ if isinstance(value, dict):
290
+ for k, val in value.items():
291
+ if "wh" in k.lower(): # which
292
+ ax.grid(
293
+ which=val
294
+ ) # {'major', 'minor', 'both'}, default: 'major'
295
+ elif "ax" in k.lower(): # ax
296
+ ax.grid(axis=val) # {'x', 'y', 'both'}, default: 'both'
297
+ elif ("c" in k.lower()) and ("ect" not in k.lower()): # c: color
298
+ ax.grid(color=val) # Tick color.
299
+ elif "l" in k.lower() and ("s" in k.lower()):# ls:line stype
300
+ ax.grid(linestyle=val)
301
+ elif "l" in k.lower() and ("w" in k.lower()): # lw: line width
302
+ ax.grid(linewidth=val)
303
+ elif "al" in k.lower():# alpha:
304
+ ax.grid(alpha=val)
305
+ else:
306
+ if value == "on" or value is True:
307
+ ax.grid(visible=True)
308
+ elif value == "off" or value is False:
309
+ ax.grid(visible=False)
310
+ if "tit" in key.lower():
311
+ if "sup" in key.lower():
312
+ plt.suptitle(value)
313
+ else:
314
+ ax.set_title(value)
315
+ if key.lower() in ["spine", "adjust", "ad", "sp", "spi", "adj","spines"]:
316
+ if isinstance(value, bool) or (value in ["go", "do", "ja", "yes"]):
317
+ if value:
318
+ adjust_spines(ax) # dafault distance=2
319
+ if isinstance(value, (float, int)):
320
+ adjust_spines(ax=ax, distance=value)
321
+ if "c" in key.lower() and ("sp" in key.lower() or "ax" in key.lower()):# spine color
322
+ for loc, spi in ax.spines.items():
323
+ spi.set_color(value)
324
+ if 'leg' in key.lower(): # legend
325
+ legend_kws = kwargs.get('legend', None)
326
+ if legend_kws:
327
+ # https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html
328
+ ax.legend(**legend_kws)
329
+
330
+ for arg in args:
331
+ if isinstance(arg,matplotlib.axes._axes.Axes):
332
+ ax=arg
333
+ args=args[1:]
334
+ ax = kwargs.get('ax',plt.gca())
335
+ if 'ax' not in locals() or ax is None:
336
+ ax=plt.gca()
337
+ for key, value in kwargs.items():
338
+ set_step_1(ax, key, value)
339
+ set_step_2(ax, key, value)
340
+ for arg in args:
341
+ if isinstance(arg, dict):
342
+ for k, val in arg.items():
343
+ set_step_1(ax,k, val)
344
+ for k, val in arg.items():
345
+ set_step_2(ax,k, val)
346
+ else:
347
+ Nargin = len(args) // 2
348
+ ax.labelFontSizeMultiplier = 1
349
+ ax.titleFontSizeMultiplier = 1
350
+ ax.set_facecolor("w")
351
+
352
+ for ip in range(Nargin):
353
+ key = args[ip * 2].lower()
354
+ value = args[ip * 2 + 1]
355
+ set_step_1(ax,key, value)
356
+ for ip in range(Nargin):
357
+ key = args[ip * 2].lower()
358
+ value = args[ip * 2 + 1]
359
+ set_step_2(ax,key, value)
360
+ colors = [
361
+ "#474747",
362
+ "#FF2C00",
363
+ "#0C5DA5",
364
+ "#845B97",
365
+ "#58BBCC",
366
+ "#FF9500",
367
+ "#D57DBE",
368
+ ]
369
+ matplotlib.rcParams["axes.prop_cycle"] = cycler(color=colors)
370
+ if len(fig.get_axes()) > 1:
371
+ plt.tight_layout()
372
+ plt.gcf().align_labels()
@@ -0,0 +1,68 @@
1
+
2
+ from cycler import cycler
3
+
4
+ # set up the colorlist, give the number, or the colormap's name
5
+ def get_color(n=1, cmap="auto", by="start"):
6
+ # Extract the colormap as a list
7
+ def cmap2hex(cmap_name):
8
+ cmap_ = matplotlib.pyplot.get_cmap(cmap_name)
9
+ colors = [cmap_(i) for i in range(cmap_.N)]
10
+ return [matplotlib.colors.rgb2hex(color) for color in colors]
11
+ # usage: clist = cmap2hex("viridis")
12
+ # cycle times, total number is n (defaultn=10)
13
+ def cycle2list(colorlist, n=10):
14
+ cycler_ = cycler(tmp=colorlist)
15
+ clist = []
16
+ for i, c_ in zip(range(n), cycler_()):
17
+ clist.append(c_["tmp"])
18
+ if i > n:
19
+ break
20
+ return clist
21
+ def hue2rgb(hex_colors):
22
+ def hex_to_rgb(hex_color):
23
+ """Converts a hexadecimal color code to RGB values."""
24
+ if hex_colors.startswith("#"):
25
+ hex_color = hex_color.lstrip("#")
26
+ return tuple(int(hex_color[i : i + 2], 16) / 255.0 for i in (0, 2, 4))
27
+ if isinstance(hex_colors, str):
28
+ return hex_to_rgb(hex_colors)
29
+ elif isinstance(hex_colors, (list)):
30
+ """Converts a list of hexadecimal color codes to a list of RGB values."""
31
+ rgb_values = [hex_to_rgb(hex_color) for hex_color in hex_colors]
32
+ return rgb_values
33
+ if "aut" in cmap:
34
+ colorlist = [
35
+ "#474747",
36
+ "#FF2C00",
37
+ "#0C5DA5",
38
+ "#845B97",
39
+ "#58BBCC",
40
+ "#FF9500",
41
+ "#D57DBE",
42
+ ]
43
+ else:
44
+ colorlist = cmap2hex(cmap)
45
+ if "st" in by.lower() or "be" in by.lower():
46
+ # cycle it
47
+ clist = cycle2list(colorlist, n=n)
48
+ if "l" in by.lower() or "p" in by.lower():
49
+ clist = []
50
+ [
51
+ clist.append(colorlist[i])
52
+ for i in [int(i) for i in np.linspace(0, len(colorlist) - 1, n)]
53
+ ]
54
+
55
+ return clist # a color list
56
+ # example usage: clist = get_color(4,cmap="auto", by="start") # get_color(4, cmap="hot", by="linspace")
57
+
58
+ """
59
+ # n = 7
60
+ # clist = get_color(n, cmap="auto", by="linspace") # get_color(100)
61
+ # plt.figure(figsize=[8, 5], dpi=100)
62
+ # x = np.linspace(0, 2 * np.pi, 50) * 100
63
+ # y = np.sin(x)
64
+ # for i in range(1, n + 1):
65
+ # plt.plot(x, y + i, c=clist[i - 1], lw=5, label=str(i))
66
+ # plt.legend()
67
+ # plt.ylim(-2, 20)
68
+ # figsets(plt.gca(), {"style": "whitegrid"}) """
py2ls/plot/stdshade.py ADDED
@@ -0,0 +1,227 @@
1
+ from scipy.signal import savgol_filter
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+
5
+ def stdshade(ax=None,*args, **kwargs):
6
+ # Separate kws_line and kws_fill if necessary
7
+ kws_line = kwargs.pop('kws_line', {})
8
+ kws_fill = kwargs.pop('kws_fill', {})
9
+
10
+ # Merge kws_line and kws_fill into kwargs
11
+ kwargs.update(kws_line)
12
+ kwargs.update(kws_fill)
13
+ def str2list(str_):
14
+ l = []
15
+ [l.append(x) for x in str_]
16
+ return l
17
+ def hue2rgb(hex_colors):
18
+ def hex_to_rgb(hex_color):
19
+ """Converts a hexadecimal color code to RGB values."""
20
+ if hex_colors.startswith("#"):
21
+ hex_color = hex_color.lstrip("#")
22
+ return tuple(int(hex_color[i : i + 2], 16) / 255.0 for i in (0, 2, 4))
23
+ if isinstance(hex_colors, str):
24
+ return hex_to_rgb(hex_colors)
25
+ elif isinstance(hex_colors, (list)):
26
+ """Converts a list of hexadecimal color codes to a list of RGB values."""
27
+ rgb_values = [hex_to_rgb(hex_color) for hex_color in hex_colors]
28
+ return rgb_values
29
+ if (
30
+ isinstance(ax, np.ndarray)
31
+ and ax.ndim == 2
32
+ and min(ax.shape) > 1
33
+ and max(ax.shape) > 1
34
+ ):
35
+ y = ax
36
+ ax = plt.gca()
37
+ if ax is None:
38
+ ax = plt.gca()
39
+ alpha = 0.5
40
+ acolor = "k"
41
+ paraStdSem = "sem"
42
+ plotStyle = "-"
43
+ plotMarker = "none"
44
+ smth = 1
45
+ l_c_one = ["r", "g", "b", "m", "c", "y", "k", "w"]
46
+ l_style2 = ["--", "-."]
47
+ l_style1 = ["-", ":"]
48
+ l_mark = ["o", "+", "*", ".", "x", "_", "|", "s", "d", "^", "v", ">", "<", "p", "h"]
49
+ # Check each argument
50
+ for iarg in range(len(args)):
51
+ if (
52
+ isinstance(args[iarg], np.ndarray)
53
+ and args[iarg].ndim == 2
54
+ and min(args[iarg].shape) > 1
55
+ and max(args[iarg].shape) > 1
56
+ ):
57
+ y = args[iarg]
58
+ # Except y, continuous data is 'F'
59
+ if (isinstance(args[iarg], np.ndarray) and args[iarg].ndim == 1) or isinstance(
60
+ args[iarg], range
61
+ ):
62
+ x = args[iarg]
63
+ if isinstance(x, range):
64
+ x = np.arange(start=x.start, stop=x.stop, step=x.step)
65
+ # Only one number( 0~1), 'alpha' / color
66
+ if isinstance(args[iarg], (int, float)):
67
+ if np.size(args[iarg]) == 1 and 0 <= args[iarg] <= 1:
68
+ alpha = args[iarg]
69
+ if isinstance(args[iarg], (list, tuple)) and np.size(args[iarg]) == 3:
70
+ acolor = args[iarg]
71
+ acolor = tuple(acolor) if isinstance(acolor, list) else acolor
72
+ # Color / plotStyle /
73
+ if (
74
+ isinstance(args[iarg], str)
75
+ and len(args[iarg]) == 1
76
+ and args[iarg] in l_c_one
77
+ ):
78
+ acolor = args[iarg]
79
+ else:
80
+ if isinstance(args[iarg], str):
81
+ if args[iarg] in ["sem", "std"]:
82
+ paraStdSem = args[iarg]
83
+ if args[iarg].startswith("#"):
84
+ acolor=hue2rgb(args[iarg])
85
+ if str2list(args[iarg])[0] in l_c_one:
86
+ if len(args[iarg]) == 3:
87
+ k = [i for i in str2list(args[iarg]) if i in l_c_one]
88
+ if k != []:
89
+ acolor = k[0]
90
+ st = [i for i in l_style2 if i in args[iarg]]
91
+ if st != []:
92
+ plotStyle = st[0]
93
+ elif len(args[iarg]) == 2:
94
+ k = [i for i in str2list(args[iarg]) if i in l_c_one]
95
+ if k != []:
96
+ acolor = k[0]
97
+ mk = [i for i in str2list(args[iarg]) if i in l_mark]
98
+ if mk != []:
99
+ plotMarker = mk[0]
100
+ st = [i for i in l_style1 if i in args[iarg]]
101
+ if st != []:
102
+ plotStyle = st[0]
103
+ if len(args[iarg]) == 1:
104
+ k = [i for i in str2list(args[iarg]) if i in l_c_one]
105
+ if k != []:
106
+ acolor = k[0]
107
+ mk = [i for i in str2list(args[iarg]) if i in l_mark]
108
+ if mk != []:
109
+ plotMarker = mk[0]
110
+ st = [i for i in l_style1 if i in args[iarg]]
111
+ if st != []:
112
+ plotStyle = st[0]
113
+ if len(args[iarg]) == 2:
114
+ st = [i for i in l_style2 if i in args[iarg]]
115
+ if st != []:
116
+ plotStyle = st[0]
117
+ # smth
118
+ if (
119
+ isinstance(args[iarg], (int, float))
120
+ and np.size(args[iarg]) == 1
121
+ and args[iarg] >= 1
122
+ ):
123
+ smth = args[iarg]
124
+ smth = kwargs.get('smth', smth)
125
+ if "x" not in locals() or x is None:
126
+ x = np.arange(1, y.shape[1] + 1)
127
+ elif len(x) < y.shape[1]:
128
+ y = y[:, x]
129
+ nRow = y.shape[0]
130
+ nCol = y.shape[1]
131
+ print(f"y was corrected, please confirm that {nRow} row, {nCol} col")
132
+ else:
133
+ x = np.arange(1, y.shape[1] + 1)
134
+
135
+ if x.shape[0] != 1:
136
+ x = x.T
137
+ yMean = np.nanmean(y, axis=0)
138
+ if smth > 1:
139
+ yMean = savgol_filter(np.nanmean(y, axis=0), smth, 1)
140
+ else:
141
+ yMean = np.nanmean(y, axis=0)
142
+ if paraStdSem == "sem":
143
+ if smth > 1:
144
+ wings = savgol_filter(np.nanstd(y, axis=0) / np.sqrt(y.shape[0]), smth, 1)
145
+ else:
146
+ wings = np.nanstd(y, axis=0) / np.sqrt(y.shape[0])
147
+ elif paraStdSem == "std":
148
+ if smth > 1:
149
+ wings = savgol_filter(np.nanstd(y, axis=0), smth, 1)
150
+ else:
151
+ wings = np.nanstd(y, axis=0)
152
+
153
+ # fill_kws = kwargs.get('fill_kws', {})
154
+ # line_kws = kwargs.get('line_kws', {})
155
+
156
+ # setting form kwargs
157
+ lw = kwargs.get('lw', 1.5)
158
+ ls= kwargs.get('ls', plotStyle)
159
+ marker=kwargs.get("marker",plotMarker)
160
+ label=kwargs.get("label",None)
161
+ label_line = kwargs.get("label_line",None)
162
+ label_fill = kwargs.get('label_fill',None)
163
+ alpha=kwargs.get('alpha',alpha)
164
+ color=kwargs.get('color', acolor)
165
+ if not label_line and label:
166
+ label_line = label
167
+ kwargs['lw'] = lw
168
+ kwargs['ls'] = ls
169
+ kwargs['label_line'] = label_line
170
+ kwargs['label_fill'] = label_fill
171
+
172
+ # set kws_line
173
+ if 'color' not in kws_line:
174
+ kws_line['color']=color
175
+ if 'lw' not in kws_line:
176
+ kws_line['lw']=lw
177
+ if 'ls' not in kws_line:
178
+ kws_line['ls']=ls
179
+ if 'marker' not in kws_line:
180
+ kws_line['marker']=marker
181
+ if 'label' not in kws_line:
182
+ kws_line['label']=label_line
183
+
184
+ # set kws_line
185
+ if 'color' not in kws_fill:
186
+ kws_fill['color']=color
187
+ if 'alpha' not in kws_fill:
188
+ kws_fill['alpha']=alpha
189
+ if 'lw' not in kws_fill:
190
+ kws_fill['lw']=0
191
+ if 'label' not in kws_fill:
192
+ kws_fill['label']=label_fill
193
+
194
+ fill = ax.fill_between(x, yMean + wings, yMean - wings, **kws_fill)
195
+ line = ax.plot(x, yMean, **kws_line)
196
+ return line[0], fill
197
+
198
+
199
+ """
200
+ ########## Usage 1 ##########
201
+ plot.stdshade(data,
202
+ 'b',
203
+ ':',
204
+ 'd',
205
+ 0.1,
206
+ 4,
207
+ label='ddd',
208
+ label_line='label_line',
209
+ label_fill="label-fill")
210
+ plt.legend()
211
+
212
+ ########## Usage 2 ##########
213
+ plot.stdshade(data,
214
+ 'm-',
215
+ alpha=0.1,
216
+ lw=2,
217
+ ls=':',
218
+ marker='d',
219
+ color='b',
220
+ smth=4,
221
+ label='ddd',
222
+ label_line='label_line',
223
+ label_fill="label-fill")
224
+ plt.legend()
225
+
226
+ """
227
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2ls
3
- Version: 0.1.6.0
3
+ Version: 0.1.6.2
4
4
  Summary: py(thon)2(too)ls
5
5
  Author: Jianfeng
6
6
  Author-email: Jianfeng.Liu0413@gmail.com