py2ls 0.1.6.2__py3-none-any.whl → 0.1.6.3__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/ips.py +0 -344
- py2ls/plot.py +1109 -0
- {py2ls-0.1.6.2.dist-info → py2ls-0.1.6.3.dist-info}/METADATA +1 -1
- {py2ls-0.1.6.2.dist-info → py2ls-0.1.6.3.dist-info}/RECORD +5 -8
- py2ls/plot/catplot.py +0 -437
- py2ls/plot/figsets.py +0 -372
- py2ls/plot/get_color.py +0 -68
- py2ls/plot/stdshade.py +0 -227
- {py2ls-0.1.6.2.dist-info → py2ls-0.1.6.3.dist-info}/WHEEL +0 -0
py2ls/ips.py
CHANGED
|
@@ -2012,350 +2012,6 @@ def imgsets(
|
|
|
2012
2012
|
# show_axis=True,
|
|
2013
2013
|
# )
|
|
2014
2014
|
|
|
2015
|
-
def figsets(*args,**kwargs):
|
|
2016
|
-
"""
|
|
2017
|
-
usage:
|
|
2018
|
-
figsets(ax=axs[1],
|
|
2019
|
-
ylim=[0, 10],
|
|
2020
|
-
spine=2,
|
|
2021
|
-
xticklabel=['wake','sleep'],
|
|
2022
|
-
yticksdddd=np.arange(0,316,60),
|
|
2023
|
-
labels_loc=['right','top'],
|
|
2024
|
-
ticks=dict(
|
|
2025
|
-
ax='x',
|
|
2026
|
-
which='minor',
|
|
2027
|
-
direction='out',
|
|
2028
|
-
width=2,
|
|
2029
|
-
length=2,
|
|
2030
|
-
c_tick='m',
|
|
2031
|
-
pad=5,
|
|
2032
|
-
label_size=11),
|
|
2033
|
-
grid=dict(which='minor',
|
|
2034
|
-
ax='x',
|
|
2035
|
-
alpha=.4,
|
|
2036
|
-
c='b',
|
|
2037
|
-
ls='-.',
|
|
2038
|
-
lw=0.75,
|
|
2039
|
-
),
|
|
2040
|
-
supertitleddddd=f'sleep druations\n(min)',
|
|
2041
|
-
c_spine='r',
|
|
2042
|
-
minor_ticks='xy',
|
|
2043
|
-
style='paper',
|
|
2044
|
-
box=['right','bottom'],
|
|
2045
|
-
xrot=-45,
|
|
2046
|
-
yangle=20,
|
|
2047
|
-
font_sz = 2,
|
|
2048
|
-
legend=dict(labels=['group_a','group_b'],
|
|
2049
|
-
loc='upper left',
|
|
2050
|
-
edgecolor='k',
|
|
2051
|
-
facecolor='r',
|
|
2052
|
-
title='title',
|
|
2053
|
-
fancybox=1,
|
|
2054
|
-
shadow=1,
|
|
2055
|
-
ncols=4,
|
|
2056
|
-
bbox_to_anchor=[-0.5,0.7],
|
|
2057
|
-
alignment='left')
|
|
2058
|
-
)
|
|
2059
|
-
"""
|
|
2060
|
-
fig = plt.gcf()
|
|
2061
|
-
fontsize = 11
|
|
2062
|
-
fontname = "Arial"
|
|
2063
|
-
sns_themes = ["white", "whitegrid", "dark", "darkgrid", "ticks"]
|
|
2064
|
-
sns_contexts = ["notebook", "talk", "poster"] # now available "paper"
|
|
2065
|
-
scienceplots_styles = ["science","nature",
|
|
2066
|
-
"scatter","ieee","no-latex","std-colors","high-vis","bright","dark_background","science",
|
|
2067
|
-
"high-vis","vibrant","muted","retro","grid","high-contrast","light","cjk-tc-font","cjk-kr-font",
|
|
2068
|
-
]
|
|
2069
|
-
def set_step_1(ax,key, value):
|
|
2070
|
-
if ("fo" in key) and (("size" in key) or ("sz" in key)):
|
|
2071
|
-
fontsize=value
|
|
2072
|
-
plt.rcParams.update({"font.size": value})
|
|
2073
|
-
# style
|
|
2074
|
-
if "st" in key.lower() or "th" in key.lower():
|
|
2075
|
-
if isinstance(value, str):
|
|
2076
|
-
if (value in plt.style.available) or (value in scienceplots_styles):
|
|
2077
|
-
plt.style.use(value)
|
|
2078
|
-
elif value in sns_themes:
|
|
2079
|
-
sns.set_style(value)
|
|
2080
|
-
elif value in sns_contexts:
|
|
2081
|
-
sns.set_context(value)
|
|
2082
|
-
else:
|
|
2083
|
-
print(
|
|
2084
|
-
f"\nWarning\n'{value}' is not a plt.style,select on below:\n{plt.style.available+sns_themes+sns_contexts+scienceplots_styles}"
|
|
2085
|
-
)
|
|
2086
|
-
if isinstance(value, list):
|
|
2087
|
-
for i in value:
|
|
2088
|
-
if (i in plt.style.available) or (i in scienceplots_styles):
|
|
2089
|
-
plt.style.use(i)
|
|
2090
|
-
elif i in sns_themes:
|
|
2091
|
-
sns.set_style(i)
|
|
2092
|
-
elif i in sns_contexts:
|
|
2093
|
-
sns.set_context(i)
|
|
2094
|
-
else:
|
|
2095
|
-
print(
|
|
2096
|
-
f"\nWarning\n'{i}' is not a plt.style,select on below:\n{plt.style.available+sns_themes+sns_contexts+scienceplots_styles}"
|
|
2097
|
-
)
|
|
2098
|
-
if "la" in key.lower():
|
|
2099
|
-
if "loc" in key.lower() or "po" in key.lower():
|
|
2100
|
-
for i in value:
|
|
2101
|
-
if "l" in i.lower() and not 'g' in i.lower():
|
|
2102
|
-
ax.yaxis.set_label_position("left")
|
|
2103
|
-
if "r" in i.lower() and not 'o' in i.lower():
|
|
2104
|
-
ax.yaxis.set_label_position("right")
|
|
2105
|
-
if "t" in i.lower() and not 'l' in i.lower():
|
|
2106
|
-
ax.xaxis.set_label_position("top")
|
|
2107
|
-
if "b" in i.lower()and not 'o' in i.lower():
|
|
2108
|
-
ax.xaxis.set_label_position("bottom")
|
|
2109
|
-
if ("x" in key.lower()) and (
|
|
2110
|
-
"tic" not in key.lower() and "tk" not in key.lower()
|
|
2111
|
-
):
|
|
2112
|
-
ax.set_xlabel(value, fontname=fontname)
|
|
2113
|
-
if ("y" in key.lower()) and (
|
|
2114
|
-
"tic" not in key.lower() and "tk" not in key.lower()
|
|
2115
|
-
):
|
|
2116
|
-
ax.set_ylabel(value, fontname=fontname)
|
|
2117
|
-
if ("z" in key.lower()) and (
|
|
2118
|
-
"tic" not in key.lower() and "tk" not in key.lower()
|
|
2119
|
-
):
|
|
2120
|
-
ax.set_zlabel(value, fontname=fontname)
|
|
2121
|
-
if key=='xlabel' and isinstance(value,dict):
|
|
2122
|
-
ax.set_xlabel(**value)
|
|
2123
|
-
if key=='ylabel' and isinstance(value,dict):
|
|
2124
|
-
ax.set_ylabel(**value)
|
|
2125
|
-
# tick location
|
|
2126
|
-
if "tic" in key.lower() or "tk" in key.lower():
|
|
2127
|
-
if ("loc" in key.lower()) or ("po" in key.lower()):
|
|
2128
|
-
if isinstance(value,str):
|
|
2129
|
-
value=[value]
|
|
2130
|
-
if isinstance(value, list):
|
|
2131
|
-
loc = []
|
|
2132
|
-
for i in value:
|
|
2133
|
-
if ("l" in i.lower()) and ("a" not in i.lower()):
|
|
2134
|
-
ax.yaxis.set_ticks_position("left")
|
|
2135
|
-
if "r" in i.lower():
|
|
2136
|
-
ax.yaxis.set_ticks_position("right")
|
|
2137
|
-
if "t" in i.lower():
|
|
2138
|
-
ax.xaxis.set_ticks_position("top")
|
|
2139
|
-
if "b" in i.lower():
|
|
2140
|
-
ax.xaxis.set_ticks_position("bottom")
|
|
2141
|
-
if i.lower() in ["a", "both", "all", "al", ":"]:
|
|
2142
|
-
ax.xaxis.set_ticks_position("both")
|
|
2143
|
-
ax.yaxis.set_ticks_position("both")
|
|
2144
|
-
if i.lower() in ["xnone",'xoff',"none"]:
|
|
2145
|
-
ax.xaxis.set_ticks_position("none")
|
|
2146
|
-
if i.lower() in ["ynone",'yoff','none']:
|
|
2147
|
-
ax.yaxis.set_ticks_position("none")
|
|
2148
|
-
# ticks / labels
|
|
2149
|
-
elif "x" in key.lower():
|
|
2150
|
-
if value is None:
|
|
2151
|
-
value=[]
|
|
2152
|
-
if "la" not in key.lower():
|
|
2153
|
-
ax.set_xticks(value)
|
|
2154
|
-
if "la" in key.lower():
|
|
2155
|
-
ax.set_xticklabels(value)
|
|
2156
|
-
elif "y" in key.lower():
|
|
2157
|
-
if value is None:
|
|
2158
|
-
value=[]
|
|
2159
|
-
if "la" not in key.lower():
|
|
2160
|
-
ax.set_yticks(value)
|
|
2161
|
-
if "la" in key.lower():
|
|
2162
|
-
ax.set_yticklabels(value)
|
|
2163
|
-
elif "z" in key.lower():
|
|
2164
|
-
if value is None:
|
|
2165
|
-
value=[]
|
|
2166
|
-
if "la" not in key.lower():
|
|
2167
|
-
ax.set_zticks(value)
|
|
2168
|
-
if "la" in key.lower():
|
|
2169
|
-
ax.set_zticklabels(value)
|
|
2170
|
-
# rotation
|
|
2171
|
-
if "angle" in key.lower() or ("rot" in key.lower()):
|
|
2172
|
-
if "x" in key.lower():
|
|
2173
|
-
if value in [0,90,180,270]:
|
|
2174
|
-
ax.tick_params(axis="x", rotation=value)
|
|
2175
|
-
for tick in ax.get_xticklabels():
|
|
2176
|
-
tick.set_horizontalalignment('center')
|
|
2177
|
-
elif value >0:
|
|
2178
|
-
ax.tick_params(axis="x", rotation=value)
|
|
2179
|
-
for tick in ax.get_xticklabels():
|
|
2180
|
-
tick.set_horizontalalignment('right')
|
|
2181
|
-
elif value <0:
|
|
2182
|
-
ax.tick_params(axis='x', rotation=value)
|
|
2183
|
-
for tick in ax.get_xticklabels():
|
|
2184
|
-
tick.set_horizontalalignment('left')
|
|
2185
|
-
if "y" in key.lower():
|
|
2186
|
-
ax.tick_params(axis="y", rotation=value)
|
|
2187
|
-
for tick in ax.get_yticklabels():
|
|
2188
|
-
tick.set_horizontalalignment('right')
|
|
2189
|
-
|
|
2190
|
-
if "bo" in key in key: # box setting, and ("p" in key or "l" in key):
|
|
2191
|
-
if isinstance(value, (str, list)):
|
|
2192
|
-
locations = []
|
|
2193
|
-
for i in value:
|
|
2194
|
-
if "l" in i.lower() and not 't' in i.lower():
|
|
2195
|
-
locations.append("left")
|
|
2196
|
-
if "r" in i.lower()and not 'o' in i.lower(): # right
|
|
2197
|
-
locations.append("right")
|
|
2198
|
-
if "t" in i.lower() and not 'r' in i.lower(): #top
|
|
2199
|
-
locations.append("top")
|
|
2200
|
-
if "b" in i.lower() and not 't' in i.lower():
|
|
2201
|
-
locations.append("bottom")
|
|
2202
|
-
if i.lower() in ["a", "both", "all", "al", ":"]:
|
|
2203
|
-
[
|
|
2204
|
-
locations.append(x)
|
|
2205
|
-
for x in ["left", "right", "top", "bottom"]
|
|
2206
|
-
]
|
|
2207
|
-
for i in value:
|
|
2208
|
-
if i.lower() in "none":
|
|
2209
|
-
locations = []
|
|
2210
|
-
# check spines
|
|
2211
|
-
for loc, spi in ax.spines.items():
|
|
2212
|
-
if loc in locations:
|
|
2213
|
-
spi.set_position(("outward", 0))
|
|
2214
|
-
else:
|
|
2215
|
-
spi.set_color("none") # no spine
|
|
2216
|
-
if 'tick' in key.lower(): # tick ticks tick_para ={}
|
|
2217
|
-
if isinstance(value, dict):
|
|
2218
|
-
for k, val in value.items():
|
|
2219
|
-
if "wh" in k.lower():
|
|
2220
|
-
ax.tick_params(
|
|
2221
|
-
which=val
|
|
2222
|
-
) # {'major', 'minor', 'both'}, default: 'major'
|
|
2223
|
-
elif "dir" in k.lower():
|
|
2224
|
-
ax.tick_params(direction=val) # {'in', 'out', 'inout'}
|
|
2225
|
-
elif "len" in k.lower():# length
|
|
2226
|
-
ax.tick_params(length=val)
|
|
2227
|
-
elif ("wid" in k.lower()) or ("wd" in k.lower()): # width
|
|
2228
|
-
ax.tick_params(width=val)
|
|
2229
|
-
elif "ax" in k.lower(): # ax
|
|
2230
|
-
ax.tick_params(axis=val) # {'x', 'y', 'both'}, default: 'both'
|
|
2231
|
-
elif ("c" in k.lower()) and ("ect" not in k.lower()):
|
|
2232
|
-
ax.tick_params(colors=val) # Tick color.
|
|
2233
|
-
elif "pad" in k.lower() or 'space' in k.lower():
|
|
2234
|
-
ax.tick_params(
|
|
2235
|
-
pad=val
|
|
2236
|
-
) # float, distance in points between tick and label
|
|
2237
|
-
elif (
|
|
2238
|
-
("lab" in k.lower() or 'text' in k.lower())
|
|
2239
|
-
and ("s" in k.lower())
|
|
2240
|
-
and ("z" in k.lower())
|
|
2241
|
-
): # label_size
|
|
2242
|
-
ax.tick_params(
|
|
2243
|
-
labelsize=val
|
|
2244
|
-
) # float, distance in points between tick and label
|
|
2245
|
-
|
|
2246
|
-
if "mi" in key.lower() and "tic" in key.lower():# minor_ticks
|
|
2247
|
-
if "x" in value.lower() or "x" in key.lower():
|
|
2248
|
-
ax.xaxis.set_minor_locator(tck.AutoMinorLocator()) # ax.minorticks_on()
|
|
2249
|
-
if "y" in value.lower() or "y" in key.lower():
|
|
2250
|
-
ax.yaxis.set_minor_locator(
|
|
2251
|
-
tck.AutoMinorLocator()
|
|
2252
|
-
) # ax.minorticks_off()
|
|
2253
|
-
if value.lower() in ["both", ":", "all", "a", "b", "on"]:
|
|
2254
|
-
ax.minorticks_on()
|
|
2255
|
-
if key == "colormap" or key == "cmap":
|
|
2256
|
-
plt.set_cmap(value)
|
|
2257
|
-
def set_step_2(ax,key, value):
|
|
2258
|
-
if key == "figsize":
|
|
2259
|
-
pass
|
|
2260
|
-
if "xlim" in key.lower():
|
|
2261
|
-
ax.set_xlim(value)
|
|
2262
|
-
if "ylim" in key.lower():
|
|
2263
|
-
ax.set_ylim(value)
|
|
2264
|
-
if "zlim" in key.lower():
|
|
2265
|
-
ax.set_zlim(value)
|
|
2266
|
-
if "sc" in key.lower(): #scale
|
|
2267
|
-
if "x" in key.lower():
|
|
2268
|
-
ax.set_xscale(value)
|
|
2269
|
-
if "y" in key.lower():
|
|
2270
|
-
ax.set_yscale(value)
|
|
2271
|
-
if "z" in key.lower():
|
|
2272
|
-
ax.set_zscale(value)
|
|
2273
|
-
if key == "grid":
|
|
2274
|
-
if isinstance(value, dict):
|
|
2275
|
-
for k, val in value.items():
|
|
2276
|
-
if "wh" in k.lower(): # which
|
|
2277
|
-
ax.grid(
|
|
2278
|
-
which=val
|
|
2279
|
-
) # {'major', 'minor', 'both'}, default: 'major'
|
|
2280
|
-
elif "ax" in k.lower(): # ax
|
|
2281
|
-
ax.grid(axis=val) # {'x', 'y', 'both'}, default: 'both'
|
|
2282
|
-
elif ("c" in k.lower()) and ("ect" not in k.lower()): # c: color
|
|
2283
|
-
ax.grid(color=val) # Tick color.
|
|
2284
|
-
elif "l" in k.lower() and ("s" in k.lower()):# ls:line stype
|
|
2285
|
-
ax.grid(linestyle=val)
|
|
2286
|
-
elif "l" in k.lower() and ("w" in k.lower()): # lw: line width
|
|
2287
|
-
ax.grid(linewidth=val)
|
|
2288
|
-
elif "al" in k.lower():# alpha:
|
|
2289
|
-
ax.grid(alpha=val)
|
|
2290
|
-
else:
|
|
2291
|
-
if value == "on" or value is True:
|
|
2292
|
-
ax.grid(visible=True)
|
|
2293
|
-
elif value == "off" or value is False:
|
|
2294
|
-
ax.grid(visible=False)
|
|
2295
|
-
if "tit" in key.lower():
|
|
2296
|
-
if "sup" in key.lower():
|
|
2297
|
-
plt.suptitle(value)
|
|
2298
|
-
else:
|
|
2299
|
-
ax.set_title(value)
|
|
2300
|
-
if key.lower() in ["spine", "adjust", "ad", "sp", "spi", "adj","spines"]:
|
|
2301
|
-
if isinstance(value, bool) or (value in ["go", "do", "ja", "yes"]):
|
|
2302
|
-
if value:
|
|
2303
|
-
adjust_spines(ax) # dafault distance=2
|
|
2304
|
-
if isinstance(value, (float, int)):
|
|
2305
|
-
adjust_spines(ax=ax, distance=value)
|
|
2306
|
-
if "c" in key.lower() and ("sp" in key.lower() or "ax" in key.lower()):# spine color
|
|
2307
|
-
for loc, spi in ax.spines.items():
|
|
2308
|
-
spi.set_color(value)
|
|
2309
|
-
if 'leg' in key.lower(): # legend
|
|
2310
|
-
legend_kws = kwargs.get('legend', None)
|
|
2311
|
-
if legend_kws:
|
|
2312
|
-
# https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html
|
|
2313
|
-
ax.legend(**legend_kws)
|
|
2314
|
-
|
|
2315
|
-
for arg in args:
|
|
2316
|
-
if isinstance(arg,matplotlib.axes._axes.Axes):
|
|
2317
|
-
ax=arg
|
|
2318
|
-
args=args[1:]
|
|
2319
|
-
ax = kwargs.get('ax',plt.gca())
|
|
2320
|
-
if 'ax' not in locals() or ax is None:
|
|
2321
|
-
ax=plt.gca()
|
|
2322
|
-
for key, value in kwargs.items():
|
|
2323
|
-
set_step_1(ax, key, value)
|
|
2324
|
-
set_step_2(ax, key, value)
|
|
2325
|
-
for arg in args:
|
|
2326
|
-
if isinstance(arg, dict):
|
|
2327
|
-
for k, val in arg.items():
|
|
2328
|
-
set_step_1(ax,k, val)
|
|
2329
|
-
for k, val in arg.items():
|
|
2330
|
-
set_step_2(ax,k, val)
|
|
2331
|
-
else:
|
|
2332
|
-
Nargin = len(args) // 2
|
|
2333
|
-
ax.labelFontSizeMultiplier = 1
|
|
2334
|
-
ax.titleFontSizeMultiplier = 1
|
|
2335
|
-
ax.set_facecolor("w")
|
|
2336
|
-
|
|
2337
|
-
for ip in range(Nargin):
|
|
2338
|
-
key = args[ip * 2].lower()
|
|
2339
|
-
value = args[ip * 2 + 1]
|
|
2340
|
-
set_step_1(ax,key, value)
|
|
2341
|
-
for ip in range(Nargin):
|
|
2342
|
-
key = args[ip * 2].lower()
|
|
2343
|
-
value = args[ip * 2 + 1]
|
|
2344
|
-
set_step_2(ax,key, value)
|
|
2345
|
-
colors = [
|
|
2346
|
-
"#474747",
|
|
2347
|
-
"#FF2C00",
|
|
2348
|
-
"#0C5DA5",
|
|
2349
|
-
"#845B97",
|
|
2350
|
-
"#58BBCC",
|
|
2351
|
-
"#FF9500",
|
|
2352
|
-
"#D57DBE",
|
|
2353
|
-
]
|
|
2354
|
-
matplotlib.rcParams["axes.prop_cycle"] = cycler(color=colors)
|
|
2355
|
-
if len(fig.get_axes()) > 1:
|
|
2356
|
-
plt.tight_layout()
|
|
2357
|
-
plt.gcf().align_labels()
|
|
2358
|
-
|
|
2359
2015
|
|
|
2360
2016
|
def thumbnail(dir_img_list,figsize=(10,10),dpi=100, dir_save=None, kind='.png'):
|
|
2361
2017
|
"""
|