py2ls 0.1.8.9__py3-none-any.whl → 0.1.9.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/data/.DS_Store +0 -0
- py2ls/data/styles/style1.json +145 -0
- py2ls/data/styles/style2.json +146 -0
- py2ls/data/styles/style3.json +146 -0
- py2ls/data/styles/style4.json +142 -0
- py2ls/data/styles/style5.json +142 -0
- py2ls/data/styles/style6.json +142 -0
- py2ls/plot.py +299 -246
- {py2ls-0.1.8.9.dist-info → py2ls-0.1.9.1.dist-info}/METADATA +1 -1
- {py2ls-0.1.8.9.dist-info → py2ls-0.1.9.1.dist-info}/RECORD +11 -5
- {py2ls-0.1.8.9.dist-info → py2ls-0.1.9.1.dist-info}/WHEEL +0 -0
py2ls/plot.py
CHANGED
@@ -3,12 +3,13 @@ import numpy as np
|
|
3
3
|
import pandas as pd
|
4
4
|
from matplotlib.colors import to_rgba
|
5
5
|
from scipy.stats import gaussian_kde
|
6
|
-
|
6
|
+
import seaborn as sns
|
7
7
|
import matplotlib
|
8
8
|
import matplotlib.ticker as tck
|
9
9
|
from cycler import cycler
|
10
10
|
import logging
|
11
|
-
|
11
|
+
import os
|
12
|
+
from .ips import fsave, fload, mkdir
|
12
13
|
|
13
14
|
# Suppress INFO messages from fontTools
|
14
15
|
logging.getLogger("fontTools").setLevel(logging.WARNING)
|
@@ -17,7 +18,10 @@ logging.getLogger("fontTools").setLevel(logging.WARNING)
|
|
17
18
|
def catplot(data, *args, **kwargs):
|
18
19
|
"""
|
19
20
|
catplot(data, opt=None, ax=None)
|
20
|
-
|
21
|
+
The catplot function is designed to provide a flexible way to create various types of
|
22
|
+
categorical plots. It supports multiple plot layers such as bars, error bars, scatter
|
23
|
+
plots, box plots, violin plots, and lines. Each plot type is handled by its own internal
|
24
|
+
function, allowing for separation of concerns and modularity in the design.
|
21
25
|
Args:
|
22
26
|
data (array): data matrix
|
23
27
|
"""
|
@@ -459,255 +463,296 @@ def catplot(data, *args, **kwargs):
|
|
459
463
|
# custom_order = ['s', 'bx', 'e']
|
460
464
|
# full_order = sort_catplot_layers(custom_order)
|
461
465
|
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
466
|
+
col = kwargs.get("col", None)
|
467
|
+
if not col:
|
468
|
+
# figsets
|
469
|
+
kw_figsets = kwargs.get("figsets", None)
|
470
|
+
# check the data type
|
471
|
+
if isinstance(data, pd.DataFrame):
|
472
|
+
df = data.copy()
|
473
|
+
x = kwargs.get("x", None)
|
474
|
+
y = kwargs.get("y", None)
|
475
|
+
hue = kwargs.get("hue", None)
|
476
|
+
data = df2array(data=data, x=x, y=y, hue=hue)
|
477
|
+
xticklabels = []
|
478
|
+
if hue is not None:
|
479
|
+
# for i in df[x].unique().tolist():
|
480
|
+
# for j in df[hue].unique().tolist():
|
481
|
+
# xticklabels.append(i + "-" + j)
|
482
|
+
for i in df[x].unique().tolist():
|
483
|
+
xticklabels.append(i)
|
484
|
+
x_len = len(df[x].unique().tolist())
|
485
|
+
hue_len = len(df[hue].unique().tolist())
|
486
|
+
xticks = generate_xticks_with_gap(x_len, hue_len)
|
487
|
+
xticks_x_loc = generate_xticks_x_labels(x_len, hue_len)
|
488
|
+
default_x_width = 0.85
|
489
|
+
legend_hue = df[hue].unique().tolist()
|
490
|
+
default_colors = get_color(hue_len)
|
491
|
+
else:
|
492
|
+
for i in df[x].unique().tolist():
|
493
|
+
xticklabels.append(i)
|
494
|
+
xticks = np.arange(1, len(xticklabels) + 1).tolist()
|
495
|
+
xticks_x_loc = np.arange(1, len(xticklabels) + 1).tolist()
|
496
|
+
legend_hue = xticklabels
|
497
|
+
default_colors = get_color(len(xticklabels))
|
498
|
+
default_x_width = 0.5
|
499
|
+
|
500
|
+
# when the xticklabels are too long, rotate the labels a bit
|
501
|
+
|
502
|
+
xangle = 30 if max([len(i) for i in xticklabels]) > 50 else 0
|
503
|
+
if kw_figsets is not None:
|
504
|
+
kw_figsets = {
|
505
|
+
"ylabel": y,
|
506
|
+
# "xlabel": x,
|
507
|
+
"xticks": xticks_x_loc, # xticks,
|
508
|
+
"xticklabels": xticklabels,
|
509
|
+
"xangle": xangle,
|
510
|
+
**kw_figsets,
|
511
|
+
}
|
512
|
+
else:
|
513
|
+
kw_figsets = {
|
514
|
+
"ylabel": y,
|
515
|
+
# "xlabel": x,
|
516
|
+
"xticks": xticks_x_loc, # xticks,
|
517
|
+
"xticklabels": xticklabels,
|
518
|
+
"xangle": xangle,
|
519
|
+
}
|
482
520
|
else:
|
483
|
-
|
484
|
-
xticklabels.append(i)
|
485
|
-
xticks = np.arange(1, len(xticklabels) + 1).tolist()
|
486
|
-
legend_hue = xticklabels
|
487
|
-
default_colors = get_color(len(xticklabels))
|
521
|
+
xticks = np.arange(1, data.shape[1] + 1).tolist()
|
488
522
|
default_x_width = 0.5
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
523
|
+
default_colors = get_color(len(xticks))
|
524
|
+
legend_hue = None
|
525
|
+
xangle = 0
|
526
|
+
|
527
|
+
# full_order
|
528
|
+
opt = kwargs.get("opt", {})
|
529
|
+
ax = kwargs.get("ax", None)
|
530
|
+
if "ax" not in locals() or ax is None:
|
531
|
+
ax = plt.gca()
|
532
|
+
opt.setdefault("c", default_colors)
|
533
|
+
# if len(opt["c"]) < data.shape[1]:
|
534
|
+
# additional_colors = plt.cm.winter(
|
535
|
+
# np.linspace(0, 1, data.shape[1] - len(opt["c"]))
|
536
|
+
# )
|
537
|
+
# opt["c"] = np.vstack([opt["c"], additional_colors[:, :3]])
|
538
|
+
|
539
|
+
opt.setdefault("loc", {})
|
540
|
+
opt["loc"].setdefault("go", 0)
|
541
|
+
opt["loc"].setdefault("xloc", xticks)
|
542
|
+
|
543
|
+
# export setting
|
544
|
+
opt.setdefault("style", {})
|
545
|
+
opt["style"].setdefault("export", None)
|
546
|
+
print(opt["style"])
|
547
|
+
|
548
|
+
# opt.setdefault('layer', {})
|
549
|
+
opt.setdefault("layer", ["b", "bx", "e", "v", "s", "l"])
|
550
|
+
|
551
|
+
opt.setdefault("b", {})
|
552
|
+
opt["b"].setdefault("go", 1)
|
553
|
+
opt["b"].setdefault("loc", "c")
|
554
|
+
opt["b"].setdefault("FaceColor", opt["c"])
|
555
|
+
opt["b"].setdefault("FaceAlpha", 1)
|
556
|
+
opt["b"].setdefault("EdgeColor", "k")
|
557
|
+
opt["b"].setdefault("EdgeAlpha", 1)
|
558
|
+
opt["b"].setdefault("LineStyle", "-")
|
559
|
+
opt["b"].setdefault("LineWidth", 0.8)
|
560
|
+
opt["b"].setdefault("x_width", default_x_width)
|
561
|
+
opt["b"].setdefault("ShowBaseLine", "off")
|
562
|
+
opt["b"].setdefault("hatch", None)
|
563
|
+
|
564
|
+
opt.setdefault("e", {})
|
565
|
+
opt["e"].setdefault("go", 1)
|
566
|
+
opt["e"].setdefault("loc", "l")
|
567
|
+
opt["e"].setdefault("LineWidth", 1)
|
568
|
+
opt["e"].setdefault("CapLineWidth", 1)
|
569
|
+
opt["e"].setdefault("CapSize", 2)
|
570
|
+
opt["e"].setdefault("Marker", "none")
|
571
|
+
opt["e"].setdefault("LineStyle", "none")
|
572
|
+
opt["e"].setdefault("LineColor", "k")
|
573
|
+
opt["e"].setdefault("LineJoin", "round")
|
574
|
+
opt["e"].setdefault("MarkerSize", "auto")
|
575
|
+
opt["e"].setdefault("FaceColor", opt["c"])
|
576
|
+
opt["e"].setdefault("MarkerEdgeColor", "none")
|
577
|
+
opt["e"].setdefault("Visible", True)
|
578
|
+
opt["e"].setdefault("Orientation", "vertical")
|
579
|
+
opt["e"].setdefault("error", "sem")
|
580
|
+
opt["e"].setdefault("x_width", default_x_width / 5)
|
581
|
+
opt["e"].setdefault("cap_dir", "b")
|
582
|
+
|
583
|
+
opt.setdefault("s", {})
|
584
|
+
opt["s"].setdefault("go", 1)
|
585
|
+
opt["s"].setdefault("loc", "r")
|
586
|
+
opt["s"].setdefault("FaceColor", "w")
|
587
|
+
opt["s"].setdefault("cmap", None)
|
588
|
+
opt["s"].setdefault("FaceAlpha", 1)
|
589
|
+
opt["s"].setdefault("x_width", default_x_width / 5)
|
590
|
+
opt["s"].setdefault("Marker", "o")
|
591
|
+
opt["s"].setdefault("MarkerSize", 15)
|
592
|
+
opt["s"].setdefault("LineWidth", 0.8)
|
593
|
+
opt["s"].setdefault("MarkerEdgeColor", "k")
|
594
|
+
|
595
|
+
opt.setdefault("l", {})
|
596
|
+
opt["l"].setdefault("go", 1)
|
597
|
+
opt["l"].setdefault("LineStyle", "-")
|
598
|
+
opt["l"].setdefault("LineColor", "k")
|
599
|
+
opt["l"].setdefault("LineWidth", 0.5)
|
600
|
+
opt["l"].setdefault("LineAlpha", 0.5)
|
601
|
+
|
602
|
+
opt.setdefault("bx", {})
|
603
|
+
opt["bx"].setdefault("go", 0)
|
604
|
+
opt["bx"].setdefault("loc", "r")
|
605
|
+
opt["bx"].setdefault("FaceColor", opt["c"])
|
606
|
+
opt["bx"].setdefault("EdgeColor", "k")
|
607
|
+
opt["bx"].setdefault("FaceAlpha", 0.85)
|
608
|
+
opt["bx"].setdefault("EdgeAlpha", 1)
|
609
|
+
opt["bx"].setdefault("LineStyle", "-")
|
610
|
+
opt["bx"].setdefault("x_width", default_x_width / 5)
|
611
|
+
opt["bx"].setdefault("ShowBaseLine", "off")
|
612
|
+
opt["bx"].setdefault("Notch", False)
|
613
|
+
opt["bx"].setdefault("Outliers", "on")
|
614
|
+
opt["bx"].setdefault("OutlierMarker", "+")
|
615
|
+
opt["bx"].setdefault("OutlierColor", "r")
|
616
|
+
opt["bx"].setdefault("OutlierSize", 6)
|
617
|
+
# opt['bx'].setdefault('PlotStyle', 'traditional')
|
618
|
+
# opt['bx'].setdefault('FactorDirection', 'auto')
|
619
|
+
opt["bx"].setdefault("LineWidth", 0.5)
|
620
|
+
opt["bx"].setdefault("Whisker", opt["bx"]["LineWidth"])
|
621
|
+
opt["bx"].setdefault("Orientation", "vertical")
|
622
|
+
opt["bx"].setdefault("BoxLineWidth", opt["bx"]["LineWidth"])
|
623
|
+
opt["bx"].setdefault("FaceColor", "k")
|
624
|
+
opt["bx"].setdefault("WhiskerLineStyle", "-")
|
625
|
+
opt["bx"].setdefault("WhiskerLineColor", "k")
|
626
|
+
opt["bx"].setdefault("WhiskerLineWidth", opt["bx"]["LineWidth"])
|
627
|
+
opt["bx"].setdefault("Caps", True)
|
628
|
+
opt["bx"].setdefault("CapLineColor", "k")
|
629
|
+
opt["bx"].setdefault("CapLineWidth", opt["bx"]["LineWidth"])
|
630
|
+
opt["bx"].setdefault("CapSize", 0.2)
|
631
|
+
opt["bx"].setdefault("MedianLine", True)
|
632
|
+
opt["bx"].setdefault("MedianLineStyle", "-")
|
633
|
+
opt["bx"].setdefault("MedianStyle", "line")
|
634
|
+
opt["bx"].setdefault("MedianLineColor", "k")
|
635
|
+
opt["bx"].setdefault("MedianLineWidth", opt["bx"]["LineWidth"] * 4)
|
636
|
+
opt["bx"].setdefault("MedianLineTop", False)
|
637
|
+
opt["bx"].setdefault("MeanLine", False)
|
638
|
+
opt["bx"].setdefault("showmeans", opt["bx"]["MeanLine"])
|
639
|
+
opt["bx"].setdefault("MeanLineStyle", "-")
|
640
|
+
opt["bx"].setdefault("MeanLineColor", "w")
|
641
|
+
opt["bx"].setdefault("MeanLineWidth", opt["bx"]["LineWidth"] * 4)
|
642
|
+
|
643
|
+
# Violin plot options
|
644
|
+
opt.setdefault("v", {})
|
645
|
+
opt["v"].setdefault("go", 0)
|
646
|
+
opt["v"].setdefault("x_width", 0.3)
|
647
|
+
opt["v"].setdefault("loc", "r")
|
648
|
+
opt["v"].setdefault("EdgeColor", "none")
|
649
|
+
opt["v"].setdefault("FaceColor", opt["c"])
|
650
|
+
opt["v"].setdefault("FaceAlpha", 0.3)
|
651
|
+
opt["v"].setdefault("BandWidth", "scott")
|
652
|
+
opt["v"].setdefault("Function", "pdf")
|
653
|
+
opt["v"].setdefault("Kernel", "gau")
|
654
|
+
opt["v"].setdefault("NumPoints", 500)
|
655
|
+
opt["v"].setdefault("BoundaryCorrection", "reflection")
|
656
|
+
|
657
|
+
# load style:
|
658
|
+
style_use = kwargs.get("style_use", None)
|
659
|
+
if style_use:
|
660
|
+
try:
|
661
|
+
dir_curr_script = os.path.dirname(os.path.abspath(__file__))
|
662
|
+
dir_style = dir_curr_script + "/data/styles/"
|
663
|
+
style_load = fload(dir_style + style_use + ".json")
|
664
|
+
opt.update(style_load)
|
665
|
+
except:
|
666
|
+
print(f"cannot find the style'{style_name}'")
|
667
|
+
data_m = np.nanmean(data, axis=0)
|
668
|
+
nr, nc = data.shape
|
669
|
+
|
670
|
+
for key in kwargs.keys():
|
671
|
+
if key in opt:
|
672
|
+
if isinstance(kwargs[key], dict):
|
673
|
+
opt[key].update(kwargs[key])
|
674
|
+
else:
|
675
|
+
opt[key] = kwargs[key]
|
676
|
+
if isinstance(opt["loc"]["xloc"], list):
|
677
|
+
xloc = np.array(opt["loc"]["xloc"])
|
502
678
|
else:
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
679
|
+
xloc = opt["loc"]["xloc"]
|
680
|
+
layers = sort_catplot_layers(opt["layer"])
|
681
|
+
|
682
|
+
label_which = kwargs.get("label_which", "barplot")
|
683
|
+
if "b" in label_which:
|
684
|
+
legend_which = "b"
|
685
|
+
elif "s" in label_which:
|
686
|
+
legend_which = "s"
|
687
|
+
elif "bx" in label_which:
|
688
|
+
legend_which = "bx"
|
689
|
+
elif "e" in label_which:
|
690
|
+
legend_which = "e"
|
691
|
+
elif "v" in label_which:
|
692
|
+
legend_which = "v"
|
693
|
+
else:
|
694
|
+
legend_which = None
|
514
695
|
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
opt["b"].setdefault("FaceAlpha", 1)
|
544
|
-
opt["b"].setdefault("EdgeColor", "k")
|
545
|
-
opt["b"].setdefault("EdgeAlpha", 1)
|
546
|
-
opt["b"].setdefault("LineStyle", "-")
|
547
|
-
opt["b"].setdefault("LineWidth", 0.8)
|
548
|
-
opt["b"].setdefault("x_width", default_x_width)
|
549
|
-
opt["b"].setdefault("ShowBaseLine", "off")
|
550
|
-
opt["b"].setdefault("hatch", None)
|
551
|
-
|
552
|
-
opt.setdefault("e", {})
|
553
|
-
opt["e"].setdefault("go", 1)
|
554
|
-
opt["e"].setdefault("loc", "l")
|
555
|
-
opt["e"].setdefault("LineWidth", 1)
|
556
|
-
opt["e"].setdefault("CapLineWidth", 1)
|
557
|
-
opt["e"].setdefault("CapSize", 2)
|
558
|
-
opt["e"].setdefault("Marker", "none")
|
559
|
-
opt["e"].setdefault("LineStyle", "none")
|
560
|
-
opt["e"].setdefault("LineColor", "k")
|
561
|
-
opt["e"].setdefault("LineJoin", "round")
|
562
|
-
opt["e"].setdefault("MarkerSize", "auto")
|
563
|
-
opt["e"].setdefault("FaceColor", opt["c"])
|
564
|
-
opt["e"].setdefault("MarkerEdgeColor", "none")
|
565
|
-
opt["e"].setdefault("Visible", True)
|
566
|
-
opt["e"].setdefault("Orientation", "vertical")
|
567
|
-
opt["e"].setdefault("error", "sem")
|
568
|
-
opt["e"].setdefault("x_width", opt["b"]["x_width"] / 5)
|
569
|
-
opt["e"].setdefault("cap_dir", "b")
|
570
|
-
|
571
|
-
opt.setdefault("s", {})
|
572
|
-
opt["s"].setdefault("go", 1)
|
573
|
-
opt["s"].setdefault("loc", "r")
|
574
|
-
opt["s"].setdefault("FaceColor", "w")
|
575
|
-
opt["s"].setdefault("cmap", None)
|
576
|
-
opt["s"].setdefault("FaceAlpha", 1)
|
577
|
-
opt["s"].setdefault("x_width", opt["b"]["x_width"] / 5)
|
578
|
-
opt["s"].setdefault("Marker", "o")
|
579
|
-
opt["s"].setdefault("MarkerSize", 15)
|
580
|
-
opt["s"].setdefault("LineWidth", 0.8)
|
581
|
-
opt["s"].setdefault("MarkerEdgeColor", "k")
|
582
|
-
|
583
|
-
opt.setdefault("l", {})
|
584
|
-
opt["l"].setdefault("go", 1)
|
585
|
-
opt["l"].setdefault("LineStyle", "-")
|
586
|
-
opt["l"].setdefault("LineColor", "k")
|
587
|
-
opt["l"].setdefault("LineWidth", 0.5)
|
588
|
-
opt["l"].setdefault("LineAlpha", 0.5)
|
589
|
-
|
590
|
-
opt.setdefault("bx", {})
|
591
|
-
opt["bx"].setdefault("go", 0)
|
592
|
-
opt["bx"].setdefault("loc", "r")
|
593
|
-
opt["bx"].setdefault("FaceColor", opt["c"])
|
594
|
-
opt["bx"].setdefault("EdgeColor", "k")
|
595
|
-
opt["bx"].setdefault("FaceAlpha", 0.85)
|
596
|
-
opt["bx"].setdefault("EdgeAlpha", 1)
|
597
|
-
opt["bx"].setdefault("LineStyle", "-")
|
598
|
-
opt["bx"].setdefault("x_width", 0.2)
|
599
|
-
opt["bx"].setdefault("ShowBaseLine", "off")
|
600
|
-
opt["bx"].setdefault("Notch", False)
|
601
|
-
opt["bx"].setdefault("Outliers", "on")
|
602
|
-
opt["bx"].setdefault("OutlierMarker", "+")
|
603
|
-
opt["bx"].setdefault("OutlierColor", "r")
|
604
|
-
opt["bx"].setdefault("OutlierSize", 6)
|
605
|
-
# opt['bx'].setdefault('PlotStyle', 'traditional')
|
606
|
-
# opt['bx'].setdefault('FactorDirection', 'auto')
|
607
|
-
opt["bx"].setdefault("Whisker", 0.5)
|
608
|
-
opt["bx"].setdefault("Orientation", "vertical")
|
609
|
-
opt["bx"].setdefault("BoxLineWidth", 0.5)
|
610
|
-
opt["bx"].setdefault("FaceColor", "k")
|
611
|
-
opt["bx"].setdefault("WhiskerLineStyle", "-")
|
612
|
-
opt["bx"].setdefault("WhiskerLineColor", "k")
|
613
|
-
opt["bx"].setdefault("WhiskerLineWidth", 0.5)
|
614
|
-
opt["bx"].setdefault("Caps", True)
|
615
|
-
opt["bx"].setdefault("CapLineColor", "k")
|
616
|
-
opt["bx"].setdefault("CapLineWidth", 0.5)
|
617
|
-
opt["bx"].setdefault("CapSize", 0.2)
|
618
|
-
opt["bx"].setdefault("MedianLine", True)
|
619
|
-
opt["bx"].setdefault("MedianLineStyle", "-")
|
620
|
-
opt["bx"].setdefault("MedianStyle", "line")
|
621
|
-
opt["bx"].setdefault("MedianLineColor", "k")
|
622
|
-
opt["bx"].setdefault("MedianLineWidth", 2)
|
623
|
-
opt["bx"].setdefault("MedianLineTop", False)
|
624
|
-
opt["bx"].setdefault("MeanLine", False)
|
625
|
-
opt["bx"].setdefault("showmeans", opt["bx"]["MeanLine"])
|
626
|
-
opt["bx"].setdefault("MeanLineStyle", "-")
|
627
|
-
opt["bx"].setdefault("MeanLineColor", "w")
|
628
|
-
opt["bx"].setdefault("MeanLineWidth", 2)
|
629
|
-
|
630
|
-
# Violin plot options
|
631
|
-
opt.setdefault("v", {})
|
632
|
-
opt["v"].setdefault("go", 0)
|
633
|
-
opt["v"].setdefault("x_width", 0.3)
|
634
|
-
opt["v"].setdefault("loc", "r")
|
635
|
-
opt["v"].setdefault("EdgeColor", "none")
|
636
|
-
opt["v"].setdefault("FaceColor", opt["c"])
|
637
|
-
opt["v"].setdefault("FaceAlpha", 0.3)
|
638
|
-
opt["v"].setdefault("BandWidth", "scott")
|
639
|
-
opt["v"].setdefault("Function", "pdf")
|
640
|
-
opt["v"].setdefault("Kernel", "gau")
|
641
|
-
opt["v"].setdefault("NumPoints", 500)
|
642
|
-
opt["v"].setdefault("BoundaryCorrection", "reflection")
|
643
|
-
|
644
|
-
data_m = np.nanmean(data, axis=0)
|
645
|
-
nr, nc = data.shape
|
646
|
-
|
647
|
-
for key in kwargs.keys():
|
648
|
-
if key in opt:
|
649
|
-
if isinstance(kwargs[key], dict):
|
650
|
-
opt[key].update(kwargs[key])
|
696
|
+
for layer in layers:
|
697
|
+
if layer == "b" and opt["b"]["go"]:
|
698
|
+
if legend_which == "b":
|
699
|
+
plot_bars(data, data_m, opt["b"], xloc, ax, label=legend_hue)
|
700
|
+
else:
|
701
|
+
plot_bars(data, data_m, opt["b"], xloc, ax, label=None)
|
702
|
+
elif layer == "e" and opt["e"]["go"]:
|
703
|
+
if legend_which == "e":
|
704
|
+
plot_errors(data, data_m, opt["e"], xloc, ax, label=legend_hue)
|
705
|
+
else:
|
706
|
+
plot_errors(data, data_m, opt["e"], xloc, ax, label=None)
|
707
|
+
elif layer == "s" and opt["s"]["go"]:
|
708
|
+
if legend_which == "s":
|
709
|
+
plot_scatter(data, opt["s"], xloc, ax, label=legend_hue)
|
710
|
+
else:
|
711
|
+
plot_scatter(data, opt["s"], xloc, ax, label=None)
|
712
|
+
elif layer == "bx" and opt["bx"]["go"]:
|
713
|
+
if legend_which == "bx":
|
714
|
+
plot_boxplot(data, opt["bx"], xloc, ax, label=legend_hue)
|
715
|
+
else:
|
716
|
+
plot_boxplot(data, opt["bx"], xloc, ax, label=None)
|
717
|
+
elif layer == "v" and opt["v"]["go"]:
|
718
|
+
if legend_which == "v":
|
719
|
+
plot_violin(data, opt["v"], xloc, ax, label=legend_hue)
|
720
|
+
else:
|
721
|
+
plot_violin(data, opt["v"], xloc, ax, label=None)
|
722
|
+
elif all([layer == "l", opt["l"]["go"], opt["s"]["go"]]):
|
723
|
+
plot_lines(data, opt["l"], opt["s"], ax)
|
651
724
|
else:
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
legend_which = "bx"
|
666
|
-
elif "e" in label_which:
|
667
|
-
legend_which = "e"
|
668
|
-
elif "v" in label_which:
|
669
|
-
legend_which = "v"
|
725
|
+
print("layers run some problems")
|
726
|
+
if kw_figsets is not None:
|
727
|
+
figsets(ax=ax, **kw_figsets)
|
728
|
+
show_legend = kwargs.get("show_legend", True)
|
729
|
+
if show_legend:
|
730
|
+
ax.legend()
|
731
|
+
|
732
|
+
style_export = kwargs.get("style_export", None)
|
733
|
+
if style_export and (style_export != style_use):
|
734
|
+
dir_curr_script = os.path.dirname(os.path.abspath(__file__))
|
735
|
+
dir_style = dir_curr_script + "/data/styles/"
|
736
|
+
fsave(dir_style + style_export + ".json", opt)
|
737
|
+
return ax, opt
|
670
738
|
else:
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
plot_scatter(data, opt["s"], xloc, ax, label=None)
|
689
|
-
elif layer == "bx" and opt["bx"]["go"]:
|
690
|
-
if legend_which == "bx":
|
691
|
-
plot_boxplot(data, opt["bx"], xloc, ax, label=legend_hue)
|
692
|
-
else:
|
693
|
-
plot_boxplot(data, opt["bx"], xloc, ax, label=None)
|
694
|
-
elif layer == "v" and opt["v"]["go"]:
|
695
|
-
if legend_which == "v":
|
696
|
-
plot_violin(data, opt["v"], xloc, ax, label=legend_hue)
|
697
|
-
else:
|
698
|
-
plot_violin(data, opt["v"], xloc, ax, label=None)
|
699
|
-
elif all([layer == "l", opt["l"]["go"], opt["s"]["go"]]):
|
700
|
-
plot_lines(data, opt["l"], opt["s"], ax)
|
701
|
-
|
702
|
-
if kw_figsets is not None:
|
703
|
-
figsets(ax=ax, **kw_figsets)
|
704
|
-
show_legend = kwargs.get("show_legend", True)
|
705
|
-
if show_legend:
|
706
|
-
ax.legend()
|
707
|
-
export_style = kwargs.get("export_style", None)
|
708
|
-
if export_style:
|
709
|
-
fsave(export_style, opt)
|
710
|
-
return ax, opt
|
739
|
+
col_names = data[col].unique().tolist()
|
740
|
+
nrow, ncol = kwargs.get("subplots", [len(col_names), 1])
|
741
|
+
figsize = kwargs.get("figsize", [3 * ncol, 3 * nrow])
|
742
|
+
fig, axs = plt.subplots(nrow, ncol, figsize=figsize, squeeze=False)
|
743
|
+
axs = axs.flatten()
|
744
|
+
key2rm = ["data", "ax", "col", "subplots"]
|
745
|
+
for k2rm in key2rm:
|
746
|
+
if k2rm in kwargs:
|
747
|
+
del kwargs[k2rm]
|
748
|
+
for i, ax in enumerate(axs):
|
749
|
+
# ax = axs[i][0] if len(col_names) > 1 else axs[0]
|
750
|
+
if i < len(col_names):
|
751
|
+
df_sub = data.loc[data[col] == col_names[i]]
|
752
|
+
_, opt = catplot(ax=ax, data=df_sub, **kwargs)
|
753
|
+
ax.set_title(col_names[i])
|
754
|
+
print(f"Axis layout shape: {axs.shape}")
|
755
|
+
return axs, opt
|
711
756
|
|
712
757
|
|
713
758
|
def get_cmap():
|
@@ -1675,3 +1720,11 @@ def generate_xticks_with_gap(x_len, hue_len):
|
|
1675
1720
|
positive_array = concatenated_array[concatenated_array > 0].tolist()
|
1676
1721
|
|
1677
1722
|
return positive_array
|
1723
|
+
|
1724
|
+
|
1725
|
+
def generate_xticks_x_labels(x_len, hue_len):
|
1726
|
+
arrays = [
|
1727
|
+
np.arange(1, hue_len + 1) + hue_len * (x_len - i) + (x_len - i)
|
1728
|
+
for i in range(max(x_len, hue_len), 0, -1) # i iterates from 3 to 1
|
1729
|
+
]
|
1730
|
+
return [np.mean(i) for i in arrays if np.mean(i) > 0]
|
@@ -126,22 +126,28 @@ py2ls/__init__.py,sha256=Nn8jTIvySX7t7DMJ8VNRVctTStgXGjHldOIdZ35PdW8,165
|
|
126
126
|
py2ls/brain_atlas.py,sha256=w1o5EelRjq89zuFJUNSz4Da8HnTCwAwDAZ4NU4a-bAY,5486
|
127
127
|
py2ls/chat.py,sha256=Yr22GoIvoWhpV3m4fdwV_I0Mn77La346_ymSinR-ORA,3793
|
128
128
|
py2ls/correlators.py,sha256=RbOaJIPLCHJtUm5SFi_4dCJ7VFUPWR0PErfK3K26ad4,18243
|
129
|
-
py2ls/data/.DS_Store,sha256=
|
129
|
+
py2ls/data/.DS_Store,sha256=iH2O541jT_5mlTPavY_d5V2prS9zhNx4Pv7yhmbwaHI,6148
|
130
130
|
py2ls/data/db2ls_sql_chtsht.json,sha256=ls9d7Sm8TLeujanWHfHlWhU85Qz1KnAizO_9X3wUH7E,6933
|
131
131
|
py2ls/data/docs_links.json,sha256=kXgbbWo0b8bfV4n6iuuUNLnZipIyLzokUO6Lzmf7nO4,101829
|
132
132
|
py2ls/data/lang_code_iso639.json,sha256=qZiU7H2RLJjDMXK22C-jhwzLJCI5vKmampjB1ys4ek4,2157
|
133
|
+
py2ls/data/styles/style1.json,sha256=Q3tdH0Sf08FjNUZE5mELA45JEw3BXjSAL2nLfFDn1bU,3101
|
134
|
+
py2ls/data/styles/style2.json,sha256=2xhDv-_qQOKaODy8fWRoaQk_W5-I3EdA6uh4JNnINGg,3124
|
135
|
+
py2ls/data/styles/style3.json,sha256=0lHmjFGqlf1c7HLllsgGVNFkuEsqSCicBv-iOTB9hRk,3126
|
136
|
+
py2ls/data/styles/style4.json,sha256=G8thPHwmJyS3kDletrh3NkapZ03bNfey2-zpG4erBfk,3072
|
137
|
+
py2ls/data/styles/style5.json,sha256=0bqt3CYM1iBtu_7D8LmurnZ2mlrw-zOdUMUpnUADih4,3069
|
138
|
+
py2ls/data/styles/style6.json,sha256=0bqt3CYM1iBtu_7D8LmurnZ2mlrw-zOdUMUpnUADih4,3069
|
133
139
|
py2ls/db2ls.py,sha256=MMfFX47aIPIyu7fU9aPvX9lbPRPYOpJ_VXwlnWk-8qo,13615
|
134
140
|
py2ls/doc.py,sha256=xN3g1OWfoaGUhikbJ0NqbN5eKy1VZVvWwRlhHMgyVEc,4243
|
135
141
|
py2ls/export_requirements.py,sha256=x2WgUF0jYKz9GfA1MVKN-MdsM-oQ8yUeC6Ua8oCymio,2325
|
136
142
|
py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
|
137
143
|
py2ls/ips.py,sha256=N7MdOCgJXDQu73YkJQTtDN3RSntzXX7V0MOJ1NYBLEk,100572
|
138
144
|
py2ls/netfinder.py,sha256=OMStrwMAASf1ajlyEfseoaEygo7G5WKBAFRE0LY15Lw,49477
|
139
|
-
py2ls/plot.py,sha256=
|
145
|
+
py2ls/plot.py,sha256=kR8NcWUnzqCEi0r8ZPOaOtk-S5JUuLpjq7wsWSf39wc,66893
|
140
146
|
py2ls/setuptools-70.1.0-py3-none-any.whl,sha256=2bi3cUVal8ip86s0SOvgspteEF8SKLukECi-EWmFomc,882588
|
141
147
|
py2ls/sleep_events_detectors.py,sha256=bQA3HJqv5qnYKJJEIhCyhlDtkXQfIzqksnD0YRXso68,52145
|
142
148
|
py2ls/stats.py,sha256=Wd9yCKQ_61QD29WMEgMuEcreFxF91NmlPW65iWT2B5w,39041
|
143
149
|
py2ls/translator.py,sha256=bc5FB-wqC4TtQz9gyCP1mE38HqNRJ_pmuRIgKnAlMzM,30581
|
144
150
|
py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
|
145
|
-
py2ls-0.1.
|
146
|
-
py2ls-0.1.
|
147
|
-
py2ls-0.1.
|
151
|
+
py2ls-0.1.9.1.dist-info/METADATA,sha256=XToL4jUZomQ3-3jUt-v5uSY8pFwD6YQu_qfnxLtvAog,20017
|
152
|
+
py2ls-0.1.9.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
153
|
+
py2ls-0.1.9.1.dist-info/RECORD,,
|
File without changes
|