py2ls 0.2.4.4__py3-none-any.whl → 0.2.4.6__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
@@ -11,7 +11,7 @@ import logging
11
11
  import os
12
12
  import re
13
13
  from typing import Union
14
- from .ips import fsave, fload, mkdir, listdir, figsave, strcmp, unique, get_os, ssplit,plt_font,flatten
14
+ from .ips import fsave, fload, mkdir, listdir, figsave, strcmp, unique, get_os, ssplit,flatten,plt_font
15
15
  from .stats import *
16
16
  from .netfinder import get_soup, fetch
17
17
 
@@ -1868,6 +1868,7 @@ def figsets(*args, **kwargs):
1868
1868
  plt.rcParams["font.size"]=fontsize
1869
1869
  fontname = kwargs.pop("fontname","Arial")
1870
1870
  fontname=plt_font(fontname) # 显示中文
1871
+
1871
1872
  sns_themes = ["white", "whitegrid", "dark", "darkgrid", "ticks"]
1872
1873
  sns_contexts = ["notebook", "talk", "poster"] # now available "paper"
1873
1874
  scienceplots_styles = [
@@ -2220,6 +2221,9 @@ def figsets(*args, **kwargs):
2220
2221
  legend = ax.get_legend()
2221
2222
  if legend is not None:
2222
2223
  legend.remove()
2224
+ if any(['colorbar' in key.lower(),'cbar' in key.lower()]) and "loc" in key.lower():
2225
+ cbar = ax.collections[0].colorbar # Access the colorbar from the plot
2226
+ cbar.ax.set_position(value) # [left, bottom, width, height] [0.475, 0.15, 0.04, 0.25]
2223
2227
 
2224
2228
  for arg in args:
2225
2229
  if isinstance(arg, matplotlib.axes._axes.Axes):
@@ -2708,15 +2712,45 @@ def adjust_spines(ax=None, spines=["left", "bottom"], distance=2):
2708
2712
  # And then plot the data:
2709
2713
 
2710
2714
 
2711
- def add_colorbar(im, width=None, pad=None, **kwargs):
2712
- # usage: add_colorbar(im, width=0.01, pad=0.005, label="PSD (dB)", shrink=0.8)
2713
- l, b, w, h = im.axes.get_position().bounds # get boundaries
2714
- width = width or 0.1 * w # get width of the colorbar
2715
- pad = pad or width # get pad between im and cbar
2716
- fig = im.axes.figure # get figure of image
2717
- cax = fig.add_axes([l + w + pad, b, width, h]) # define cbar Axes
2718
- return fig.colorbar(im, cax=cax, **kwargs) # draw cbar
2715
+ # def add_colorbar(im, width=None, pad=None, **kwargs):
2716
+ # # usage: add_colorbar(im, width=0.01, pad=0.005, label="PSD (dB)", shrink=0.8)
2717
+ # l, b, w, h = im.axes.get_position().bounds # get boundaries
2718
+ # width = width or 0.1 * w # get width of the colorbar
2719
+ # pad = pad or width # get pad between im and cbar
2720
+ # fig = im.axes.figure # get figure of image
2721
+ # cax = fig.add_axes([l + w + pad, b, width, h]) # define cbar Axes
2722
+ # return fig.colorbar(im, cax=cax, **kwargs) # draw cbar
2723
+
2724
+ def add_colorbar(im,
2725
+ cmap="viridis",
2726
+ vmin=-1,
2727
+ vmax=1,
2728
+ orientation='vertical',
2729
+ width_ratio=0.05,
2730
+ pad_ratio=0.02,
2731
+ shrink=1.0,
2732
+ **kwargs):
2733
+ import matplotlib as mpl
2734
+ if all([cmap, vmin, vmax]):
2735
+ norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)
2736
+ else:
2737
+ norm=False
2738
+ sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
2739
+ sm.set_array([])
2740
+ l, b, w, h = im.axes.get_position().bounds # position: left, bottom, width, height
2741
+ if orientation == 'vertical':
2742
+ width = width_ratio * w
2743
+ pad = pad_ratio * w
2744
+ cax = im.figure.add_axes([l + w + pad, b, width, h * shrink]) # Right of the image
2745
+ else:
2746
+ height = width_ratio * h
2747
+ pad = pad_ratio * h
2748
+ cax = im.figure.add_axes([l, b - height - pad, w * shrink, height]) # Below the image
2749
+ cbar=im.figure.colorbar(sm, cax=cax, orientation=orientation, **kwargs)
2750
+ return cbar
2719
2751
 
2752
+ # Usage:
2753
+ # add_colorbar(im, width_ratio=0.03, pad_ratio=0.01, orientation='horizontal', label="PSD (dB)")
2720
2754
 
2721
2755
  def generate_xticks_with_gap(x_len, hue_len):
2722
2756
  """
@@ -3129,7 +3163,7 @@ def plotxy(
3129
3163
  kws_count = kwargs.pop("kws_count", kwargs)
3130
3164
  if not kws_count.get("hue",None):
3131
3165
  kws_count.pop("palette",None)
3132
- ax = sns.countplot(data=data, x=x, ax=ax, **kws_count)
3166
+ ax = sns.countplot(data=data, x=x,y=y, ax=ax, **kws_count)
3133
3167
  elif k == "regplot":
3134
3168
  kws_reg = kwargs.pop("kws_reg", kwargs)
3135
3169
  ax = sns.regplot(data=data, x=x, y=y, ax=ax, **kws_reg)
@@ -3465,37 +3499,106 @@ def sns_func_info(dir_save=None):
3465
3499
  )
3466
3500
 
3467
3501
 
3468
-
3469
-
3470
-
3471
-
3502
+ def get_color_overlap(*colors):
3503
+ import matplotlib.colors as mcolors
3504
+
3505
+ """Blend multiple colors by averaging their RGB values."""
3506
+ rgbs = [mcolors.to_rgb(color) for color in colors]
3507
+ blended_rgb = [sum(channel) / len(channel) for channel in zip(*rgbs)]
3508
+ return mcolors.to_hex(blended_rgb)
3509
+
3510
+
3511
+ def desaturate_color(color, saturation_factor=0.5):
3512
+ """Reduce the saturation of a color by a given factor (between 0 and 1)."""
3513
+ import matplotlib.colors as mcolors
3514
+ import colorsys
3515
+ # Convert the color to RGB
3516
+ rgb = mcolors.to_rgb(color)
3517
+ # Convert RGB to HLS (Hue, Lightness, Saturation)
3518
+ h, l, s = colorsys.rgb_to_hls(*rgb)
3519
+ # Reduce the saturation
3520
+ s *= saturation_factor
3521
+ # Convert back to RGB
3522
+ return colorsys.hls_to_rgb(h, l, s)
3523
+
3524
+ def textsets(text, fontname='Arial', fontsize=11, fontweight="normal", fontstyle="normal",
3525
+ fontcolor='k', backgroundcolor=None, shadow=False, ha="center", va="center"):
3526
+ if text: # Ensure text exists
3527
+ if fontname:
3528
+ text.set_fontname(plt_font(fontname))
3529
+ if fontsize:
3530
+ text.set_fontsize(fontsize)
3531
+ if fontweight:
3532
+ text.set_fontweight(fontweight)
3533
+ if fontstyle:
3534
+ text.set_fontstyle(fontstyle)
3535
+ if fontcolor:
3536
+ text.set_color(fontcolor)
3537
+ if backgroundcolor:
3538
+ text.set_backgroundcolor(backgroundcolor)
3539
+ text.set_horizontalalignment(ha)
3540
+ text.set_verticalalignment(va)
3541
+ if shadow:
3542
+ text.set_path_effects([
3543
+ matplotlib.patheffects.withStroke(linewidth=3, foreground="gray")
3544
+ ])
3472
3545
  def venn(
3473
3546
  lists:list,
3474
- labels:list,
3547
+ labels:list=None,
3475
3548
  ax=None,
3476
3549
  colors=None,
3477
- edgecolor="0.25",
3478
- alpha=0.75,
3479
- linewidth=.75,
3550
+ edgecolor=None,
3551
+ alpha=0.5,
3552
+ saturation=.75,
3553
+ linewidth=0, # default no edge
3480
3554
  linestyle="-",
3481
3555
  fontname='Arial',
3482
- fontsize=11,
3556
+ fontsize=10,
3557
+ fontcolor='k',
3483
3558
  fontweight="normal",
3484
3559
  fontstyle="normal",
3485
- label_align="center",
3486
- label_baseline="center",
3487
- subset_fontsize=9,
3560
+ ha="center",
3561
+ va="center",
3562
+ shadow=False,
3563
+ subset_fontsize=10,
3488
3564
  subset_fontweight="normal",
3489
3565
  subset_fontstyle="normal",
3490
- subset_label_format="{:d}",
3491
- shadow=False,
3566
+ subset_fontcolor='k',
3567
+ backgroundcolor=None,
3492
3568
  custom_texts=None,
3493
- hatches=None,
3494
- per_circle_styles=None,
3569
+ show_percentages=True, # display percentage
3570
+ fmt="{:.1%}",
3571
+ ellipse_shape=False, # 椭圆形
3572
+ ellipse_scale=[1.5, 1], #not perfect, 椭圆形的形状
3495
3573
  **kwargs
3496
3574
  ):
3497
3575
  """
3498
3576
  Advanced Venn diagram plotting function with extensive customization options.
3577
+ Usage:
3578
+ # Define the two sets
3579
+ set1 = [1, 2, 3, 4, 5]
3580
+ set2 = [4, 5, 6, 7, 8]
3581
+ set3 = [1, 2, 4, 7, 9, 10, 11, 6, 103]
3582
+ _, axs = plt.subplots(1, 2)
3583
+ venn(
3584
+ [set1, set2],
3585
+ ["Set A", "Set B"],
3586
+ colors=["r", "b"],
3587
+ edgecolor="r",
3588
+ linewidth=0,
3589
+ ax=axs[0],
3590
+ )
3591
+ venn(
3592
+ [set1, set2, set3],
3593
+ ["Set A", "Set B", "Set 3"],
3594
+ colors=["r", "g", "b"],
3595
+ saturation=0.8,
3596
+ linewidth=[3, 5, 7],
3597
+ linestyle=[":", "-", "--"],
3598
+ # edgecolor="r",
3599
+ # alpha=1,
3600
+ ax=axs[1],
3601
+ )
3499
3602
 
3500
3603
  Parameters:
3501
3604
  lists: list of sets, 2 or 3 sets
@@ -3518,126 +3621,218 @@ def venn(
3518
3621
  subset_label_format: string, format for subset labels (e.g., "{:.2f}" for floats)
3519
3622
  shadow: bool, add shadow effect to the patches
3520
3623
  custom_texts: list of custom texts to replace the subset labels
3521
- hatches: list of hatch patterns for the patches
3522
- per_circle_styles: dict, custom styles for each circle (e.g., {'circle_1': {'color': 'red'}})
3523
3624
  **kwargs: additional keyword arguments passed to venn2 or venn3
3524
3625
  """
3525
3626
  if ax is None:
3526
3627
  ax = plt.gca()
3527
3628
  lists=[set(flatten(i, verbose=False)) for i in lists]
3528
3629
  # Function to apply text styles to labels
3529
- def apply_text_style(text, fontname, fontsize, fontweight, fontstyle):
3530
- if text: # Ensure text exists
3531
- if fontname:
3532
- text.set_fontname(fontname)
3533
- if fontsize:
3534
- text.set_fontsize(fontsize)
3535
- if fontweight:
3536
- text.set_fontweight(fontweight)
3537
- if fontstyle:
3538
- text.set_fontstyle(fontstyle)
3539
- # Alignment customization
3540
- text.set_horizontalalignment(label_align)
3541
- text.set_verticalalignment(label_baseline)
3542
-
3630
+ if colors is None:
3631
+ colors=["r","b"] if len(lists)==2 else ["r","g","b"]
3632
+ if labels is None:
3633
+ labels=["set1","set2"] if len(lists)==2 else ["set1","set2","set3"]
3634
+ if edgecolor is None:
3635
+ edgecolor=colors
3636
+ colors = [desaturate_color(color, saturation) for color in colors]
3637
+ # Check colors and auto-calculate overlaps
3543
3638
  if len(lists) == 2:
3639
+ def get_count_and_percentage(set_count, subset_count):
3640
+ percent = subset_count / set_count if set_count > 0 else 0
3641
+ return f"{subset_count}\n({fmt.format(percent)})" if show_percentages else f"{subset_count}"
3642
+
3544
3643
  from matplotlib_venn import venn2, venn2_circles
3644
+ # Auto-calculate overlap color for 2-set Venn diagram
3645
+ overlap_color = get_color_overlap(colors[0], colors[1]) if colors else None
3646
+
3647
+ # Draw the venn diagram
3545
3648
  v = venn2(subsets=lists, set_labels=labels, ax=ax, **kwargs)
3546
- venn_circles = venn2_circles(subsets=lists, ax=ax,color=edgecolor)
3649
+ venn_circles = venn2_circles(subsets=lists, ax=ax)
3650
+ set1,set2=lists[0],lists[1]
3651
+ v.get_patch_by_id('10').set_color(colors[0])
3652
+ v.get_patch_by_id('01').set_color(colors[1])
3653
+ v.get_patch_by_id('11').set_color(get_color_overlap(colors[0], colors[1]) if colors else None)
3654
+ # v.get_label_by_id('10').set_text(len(set1 - set2))
3655
+ # v.get_label_by_id('01').set_text(len(set2 - set1))
3656
+ # v.get_label_by_id('11').set_text(len(set1 & set2))
3657
+ v.get_label_by_id('10').set_text(get_count_and_percentage(len(set1), len(set1 - set2)))
3658
+ v.get_label_by_id('01').set_text(get_count_and_percentage(len(set2), len(set2 - set1)))
3659
+ v.get_label_by_id('11').set_text(get_count_and_percentage(len(set1 | set2), len(set1 & set2)))
3660
+
3661
+
3547
3662
  if not isinstance(linewidth,list):
3548
3663
  linewidth=[linewidth]
3549
3664
  if isinstance(linestyle,str):
3550
3665
  linestyle=[linestyle]
3666
+ if not isinstance(edgecolor, list):
3667
+ edgecolor=[edgecolor]
3551
3668
  linewidth=linewidth*2 if len(linewidth)==1 else linewidth
3552
3669
  linestyle=linestyle*2 if len(linestyle)==1 else linestyle
3670
+ edgecolor=edgecolor*2 if len(edgecolor)==1 else edgecolor
3553
3671
  for i in range(2):
3554
3672
  venn_circles[i].set_lw(linewidth[i])
3555
3673
  venn_circles[i].set_ls(linestyle[i])
3674
+ venn_circles[i].set_edgecolor(edgecolor[i])
3675
+ # 椭圆
3676
+ if ellipse_shape:
3677
+ import matplotlib.patches as patches
3678
+ for patch in v.patches:
3679
+ patch.set_visible(False) # Hide original patches if using ellipses
3680
+ center1 = v.get_circle_center(0)
3681
+ center2 = v.get_circle_center(1)
3682
+ ellipse1 = patches.Ellipse(
3683
+ (center1.x, center1.y),
3684
+ width=ellipse_scale[0],
3685
+ height=ellipse_scale[1],
3686
+ edgecolor=edgecolor[0] if edgecolor else colors[0],
3687
+ facecolor=colors[0],
3688
+ lw=linewidth if isinstance(linewidth, (int, float)) else 1.0, # Ensure lw is a number
3689
+ ls=linestyle[0],
3690
+ alpha=alpha if isinstance(alpha, (int, float)) else 0.5 # Ensure alpha is a number
3691
+ )
3692
+ ellipse2 = patches.Ellipse(
3693
+ (center2.x, center2.y),
3694
+ width=ellipse_scale[0],
3695
+ height=ellipse_scale[1],
3696
+ edgecolor=edgecolor[1] if edgecolor else colors[1],
3697
+ facecolor=colors[1],
3698
+ lw=linewidth if isinstance(linewidth, (int, float)) else 1.0, # Ensure lw is a number
3699
+ ls=linestyle[0],
3700
+ alpha=alpha if isinstance(alpha, (int, float)) else 0.5 # Ensure alpha is a number
3701
+ )
3702
+ ax.add_patch(ellipse1)
3703
+ ax.add_patch(ellipse2)
3556
3704
  # Apply styles to set labels
3557
3705
  for i, text in enumerate(v.set_labels):
3558
- apply_text_style(text, fontname, fontsize, fontweight, fontstyle)
3706
+ textsets(text, fontname=fontname, fontsize=fontsize, fontweight=fontweight, fontstyle=fontstyle,
3707
+ fontcolor=fontcolor,ha=ha,va=va,shadow=shadow)
3559
3708
 
3560
3709
  # Apply styles to subset labels
3561
3710
  for i, text in enumerate(v.subset_labels):
3562
3711
  if text: # Ensure text exists
3563
3712
  if custom_texts: # Custom text handling
3564
- text.set_text(custom_texts[i])
3565
- else: # Default subset label formatting
3566
- subset_size = (
3567
- len(lists[i % 2])
3568
- if i in [0, 1]
3569
- else len(lists[0].intersection(lists[1]))
3570
- )
3571
- text.set_text(subset_label_format.format(subset_size))
3572
- apply_text_style(
3573
- text, None, subset_fontsize, subset_fontweight, subset_fontstyle
3574
- )
3713
+ text.set_text(custom_texts[i])
3714
+ textsets(text, fontname=fontname, fontsize=subset_fontsize, fontweight=subset_fontweight, fontstyle=subset_fontstyle,
3715
+ fontcolor=subset_fontcolor,ha=ha,va=va,shadow=shadow)
3716
+
3575
3717
  elif len(lists) == 3:
3718
+ def get_label(set_count, subset_count):
3719
+ percent = subset_count / set_count if set_count > 0 else 0
3720
+ return f"{subset_count}\n({fmt.format(percent)})" if show_percentages else f"{subset_count}"
3721
+
3576
3722
  from matplotlib_venn import venn3, venn3_circles
3577
- v = venn3(
3578
- subsets=lists, set_labels=labels, set_colors=colors, ax=ax, **kwargs
3579
- )
3580
- venn_circles = venn3_circles(
3581
- subsets=lists, ax=ax,color=edgecolor
3582
- )
3583
- if not isinstance(linewidth,list):
3584
- linewidth=[linewidth]
3585
- if isinstance(linestyle,str):
3586
- linestyle=[linestyle]
3587
- linewidth=linewidth*3 if len(linewidth)==1 else linewidth
3588
- linestyle=linestyle*3 if len(linestyle)==1 else linestyle
3589
- for i in range(3):
3590
- venn_circles[i].set_lw(linewidth[i])
3591
- venn_circles[i].set_ls(linestyle[i])
3723
+ # Auto-calculate overlap colors for 3-set Venn diagram
3724
+ colorAB = get_color_overlap(colors[0], colors[1]) if colors else None
3725
+ colorAC = get_color_overlap(colors[0], colors[2]) if colors else None
3726
+ colorBC = get_color_overlap(colors[1], colors[2]) if colors else None
3727
+ colorABC = get_color_overlap(colors[0], colors[1], colors[2]) if colors else None
3728
+ set1,set2,set3=lists[0],lists[1],lists[2]
3729
+
3730
+ # Draw the venn diagram
3731
+ v = venn3(subsets=lists, set_labels=labels, ax=ax,**kwargs)
3732
+ v.get_patch_by_id('100').set_color(colors[0])
3733
+ v.get_patch_by_id('010').set_color(colors[1])
3734
+ v.get_patch_by_id('001').set_color(colors[2])
3735
+ v.get_patch_by_id('110').set_color(colorAB)
3736
+ v.get_patch_by_id('101').set_color(colorAC)
3737
+ v.get_patch_by_id('011').set_color(colorBC)
3738
+ v.get_patch_by_id('111').set_color(colorABC)
3739
+
3740
+ # Correctly labeling subset sizes
3741
+ # v.get_label_by_id('100').set_text(len(set1 - set2 - set3))
3742
+ # v.get_label_by_id('010').set_text(len(set2 - set1 - set3))
3743
+ # v.get_label_by_id('001').set_text(len(set3 - set1 - set2))
3744
+ # v.get_label_by_id('110').set_text(len(set1 & set2 - set3))
3745
+ # v.get_label_by_id('101').set_text(len(set1 & set3 - set2))
3746
+ # v.get_label_by_id('011').set_text(len(set2 & set3 - set1))
3747
+ # v.get_label_by_id('111').set_text(len(set1 & set2 & set3))
3748
+ v.get_label_by_id('100').set_text(get_label(len(set1), len(set1 - set2 - set3)))
3749
+ v.get_label_by_id('010').set_text(get_label(len(set2), len(set2 - set1 - set3)))
3750
+ v.get_label_by_id('001').set_text(get_label(len(set3), len(set3 - set1 - set2)))
3751
+ v.get_label_by_id('110').set_text(get_label(len(set1 | set2), len(set1 & set2 - set3)))
3752
+ v.get_label_by_id('101').set_text(get_label(len(set1 | set3), len(set1 & set3 - set2)))
3753
+ v.get_label_by_id('011').set_text(get_label(len(set2 | set3), len(set2 & set3 - set1)))
3754
+ v.get_label_by_id('111').set_text(get_label(len(set1 | set2 | set3), len(set1 & set2 & set3)))
3755
+
3592
3756
 
3593
3757
  # Apply styles to set labels
3594
3758
  for i, text in enumerate(v.set_labels):
3595
- apply_text_style(text, fontname, fontsize, fontweight, fontstyle)
3759
+ textsets(text, fontname=fontname, fontsize=fontsize, fontweight=fontweight, fontstyle=fontstyle,
3760
+ fontcolor=fontcolor,ha=ha,va=va,shadow=shadow)
3596
3761
 
3597
3762
  # Apply styles to subset labels
3598
3763
  for i, text in enumerate(v.subset_labels):
3599
3764
  if text: # Ensure text exists
3600
3765
  if custom_texts: # Custom text handling
3601
3766
  text.set_text(custom_texts[i])
3602
- else: # Default subset label formatting
3603
- subset_size = (
3604
- len(lists[i])
3605
- if i < 3
3606
- else len(lists[0].intersection(lists[1], lists[2]))
3607
- )
3608
- text.set_text(subset_label_format.format(subset_size))
3609
- apply_text_style(
3610
- text, None, subset_fontsize, subset_fontweight, subset_fontstyle
3611
- )
3767
+ textsets(text, fontname=fontname, fontsize=subset_fontsize, fontweight=subset_fontweight, fontstyle=subset_fontstyle,
3768
+ fontcolor=subset_fontcolor,ha=ha,va=va,shadow=shadow)
3769
+
3770
+ venn_circles = venn3_circles(subsets=lists, ax=ax)
3771
+ if not isinstance(linewidth,list):
3772
+ linewidth=[linewidth]
3773
+ if isinstance(linestyle,str):
3774
+ linestyle=[linestyle]
3775
+ if not isinstance(edgecolor, list):
3776
+ edgecolor=[edgecolor]
3777
+ linewidth=linewidth*3 if len(linewidth)==1 else linewidth
3778
+ linestyle=linestyle*3 if len(linestyle)==1 else linestyle
3779
+ edgecolor=edgecolor*3 if len(edgecolor)==1 else edgecolor
3780
+
3781
+ # edgecolor=[to_rgba(i) for i in edgecolor]
3782
+
3783
+ for i in range(3):
3784
+ venn_circles[i].set_lw(linewidth[i])
3785
+ venn_circles[i].set_ls(linestyle[i])
3786
+ venn_circles[i].set_edgecolor(edgecolor[i])
3787
+
3788
+ #椭圆形
3789
+ if ellipse_shape:
3790
+ import matplotlib.patches as patches
3791
+ for patch in v.patches:
3792
+ patch.set_visible(False) # Hide original patches if using ellipses
3793
+ center1 = v.get_circle_center(0)
3794
+ center2 = v.get_circle_center(1)
3795
+ center3 = v.get_circle_center(2)
3796
+ ellipse1 = patches.Ellipse(
3797
+ (center1.x, center1.y),
3798
+ width=ellipse_scale[0],
3799
+ height=ellipse_scale[1],
3800
+ edgecolor=edgecolor[0] if edgecolor else colors[0],
3801
+ facecolor=colors[0],
3802
+ lw=linewidth if isinstance(linewidth, (int, float)) else 1.0, # Ensure lw is a number
3803
+ ls=linestyle[0],
3804
+ alpha=alpha if isinstance(alpha, (int, float)) else 0.5 # Ensure alpha is a number
3805
+ )
3806
+ ellipse2 = patches.Ellipse(
3807
+ (center2.x, center2.y),
3808
+ width=ellipse_scale[0],
3809
+ height=ellipse_scale[1],
3810
+ edgecolor=edgecolor[1] if edgecolor else colors[1],
3811
+ facecolor=colors[1],
3812
+ lw=linewidth if isinstance(linewidth, (int, float)) else 1.0, # Ensure lw is a number
3813
+ ls=linestyle[0],
3814
+ alpha=alpha if isinstance(alpha, (int, float)) else 0.5 # Ensure alpha is a number
3815
+ )
3816
+ ellipse3 = patches.Ellipse(
3817
+ (center3.x, center3.y),
3818
+ width=ellipse_scale[0],
3819
+ height=ellipse_scale[1],
3820
+ edgecolor=edgecolor[1] if edgecolor else colors[1],
3821
+ facecolor=colors[1],
3822
+ lw=linewidth if isinstance(linewidth, (int, float)) else 1.0, # Ensure lw is a number
3823
+ ls=linestyle[0],
3824
+ alpha=alpha if isinstance(alpha, (int, float)) else 0.5 # Ensure alpha is a number
3825
+ )
3826
+ ax.add_patch(ellipse1)
3827
+ ax.add_patch(ellipse2)
3828
+ ax.add_patch(ellipse3)
3612
3829
  else:
3613
3830
  raise ValueError("只支持2或者3个list")
3614
- # Set circle and patch customizations (edge color, transparency, hatches)
3615
- for i, patch in enumerate(v.patches):
3831
+
3832
+ # Set transparency level
3833
+ for patch in v.patches:
3616
3834
  if patch:
3617
- if colors:
3618
- patch.set_facecolor(colors[i % len(colors)])
3619
- patch.set_edgecolor("none")
3620
3835
  patch.set_alpha(alpha)
3621
- if hatches:
3622
- patch.set_hatch(hatches[i % len(hatches)])
3623
- if shadow:
3624
- from matplotlib.patches import Shadow
3625
- shadow_patch = Shadow(patch, -0.02, -0.02, alpha=0.2)
3626
- ax.add_patch(shadow_patch)
3627
- # # usage:
3628
- # venn(
3629
- # [rf_features, svm_features, lasso_features],
3630
- # ["Random Forest", "SVM-RFE", "a"],
3631
- # ax=axs[0], # Specify the axes
3632
- # colors=["#BDC8E0", "#E5C0C1", "#D0E9CB"],
3633
- # edgecolor="r",
3634
- # alpha=1,
3635
- # linewidth=[1, 2, 18],# 分别设置字体大小
3636
- # linestyle=["-", "--", ":"],
3637
- # fontsize=20,
3638
- # label_baseline="top",
3639
- # subset_label_format="{:.2f}%",
3640
- # subset_fontsize=18,
3641
- # shadow=False,
3642
- # # custom_texts=["a", "b", "c"],
3643
- # )
3836
+ if 'none' in edgecolor or 0 in linewidth:
3837
+ patch.set_edgecolor("none")
3838
+ return ax
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2ls
3
- Version: 0.2.4.4
3
+ Version: 0.2.4.6
4
4
  Summary: py(thon)2(too)ls
5
5
  Author: Jianfeng
6
6
  Author-email: Jianfeng.Liu0413@gmail.com
@@ -17,7 +17,7 @@ py2ls/.git/hooks/pre-receive.sample,sha256=pMPSuce7P9jRRBwxvU7nGlldZrRPz0ndsxAlI
17
17
  py2ls/.git/hooks/prepare-commit-msg.sample,sha256=6d3KpBif3dJe2X_Ix4nsp7bKFjkLI5KuMnbwyOGqRhk,1492
18
18
  py2ls/.git/hooks/push-to-checkout.sample,sha256=pT0HQXmLKHxt16-mSu5HPzBeZdP0lGO7nXQI7DsSv18,2783
19
19
  py2ls/.git/hooks/update.sample,sha256=jV8vqD4QPPCLV-qmdSHfkZT0XL28s32lKtWGCXoU0QY,3650
20
- py2ls/.git/index,sha256=O4t8fvweL1JsEypzrWigO2hAxCpfQwC4VOW3q8panRk,4232
20
+ py2ls/.git/index,sha256=sPKeqbWaVtDr3kILep6S-tkzgNPfGUog5UQ5meN6K-8,4232
21
21
  py2ls/.git/info/exclude,sha256=ZnH-g7egfIky7okWTR8nk7IxgFjri5jcXAbuClo7DsE,240
22
22
  py2ls/.git/logs/HEAD,sha256=8ID7WuAe_TlO9g-ARxhIJYdgdL3u3m7-1qrOanaIUlA,3535
23
23
  py2ls/.git/logs/refs/heads/main,sha256=8ID7WuAe_TlO9g-ARxhIJYdgdL3u3m7-1qrOanaIUlA,3535
@@ -173,7 +173,7 @@ py2ls/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
173
173
  py2ls/README.md,sha256=CwvJWAnSXnCnrVHlnEbrxxi6MbjbE_MT6DH2D53S818,11572
174
174
  py2ls/__init__.py,sha256=Nn8jTIvySX7t7DMJ8VNRVctTStgXGjHldOIdZ35PdW8,165
175
175
  py2ls/batman.py,sha256=E7gYofbDzN7S5oCmO_dd5Z1bxxhoYMJSD6s-VaF388E,11398
176
- py2ls/bio.py,sha256=J-zGAgHiSQwDyUvjMKDOsJZoeTkqGaXcHDYHtMd84SQ,53879
176
+ py2ls/bio.py,sha256=LN7OdnRziBwLLQ_p90Ytp7X3gf2941au-rGVbaI73Tw,86920
177
177
  py2ls/brain_atlas.py,sha256=w1o5EelRjq89zuFJUNSz4Da8HnTCwAwDAZ4NU4a-bAY,5486
178
178
  py2ls/chat.py,sha256=Yr22GoIvoWhpV3m4fdwV_I0Mn77La346_ymSinR-ORA,3793
179
179
  py2ls/correlators.py,sha256=RbOaJIPLCHJtUm5SFi_4dCJ7VFUPWR0PErfK3K26ad4,18243
@@ -214,16 +214,17 @@ py2ls/export_requirements.py,sha256=x2WgUF0jYKz9GfA1MVKN-MdsM-oQ8yUeC6Ua8oCymio,
214
214
  py2ls/fetch_update.py,sha256=9LXj661GpCEFII2wx_99aINYctDiHni6DOruDs_fdt8,4752
215
215
  py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
216
216
  py2ls/ich2ls.py,sha256=3E9R8oVpyYZXH5PiIQgT3CN5NxLe4Dwtm2LwaeacE6I,21381
217
- py2ls/ips.py,sha256=USmQKEZuqnjJyP5dhXzFG8yMrhrH6L8yt9jFtttuqLI,227772
217
+ py2ls/ips.py,sha256=qYPAjm4b5t6gs0Ep4pSBnyPt88rK8LxZ4e-c4TSIksY,228131
218
218
  py2ls/ml2ls.py,sha256=XSe2-sLNzUVSvVRkeRGfhrB_q8C49SDK1sekYC1Bats,50277
219
+ py2ls/mol.py,sha256=AZnHzarIk_MjueKdChqn1V6e4tUle3X1NnHSFA6n3Nw,10645
219
220
  py2ls/netfinder.py,sha256=RJFr80tGEJiuwEx99IBOhI5-ZuXnPdWnGUYpF7XCEwI,56426
220
221
  py2ls/ocr.py,sha256=5lhUbJufIKRSOL6wAWVLEo8TqMYSjoI_Q-IO-_4u3DE,31419
221
- py2ls/plot.py,sha256=MepTGqtxqHnc_pTixvEXjQHGPTETcTeI1FGXMxBB8L8,144556
222
+ py2ls/plot.py,sha256=qpBFmuWnn3TQancZXT08IsgSjTX33WA33I9eCRGekdw,154151
222
223
  py2ls/setuptools-70.1.0-py3-none-any.whl,sha256=2bi3cUVal8ip86s0SOvgspteEF8SKLukECi-EWmFomc,882588
223
224
  py2ls/sleep_events_detectors.py,sha256=bQA3HJqv5qnYKJJEIhCyhlDtkXQfIzqksnD0YRXso68,52145
224
225
  py2ls/stats.py,sha256=DMoJd8Z5YV9T1wB-4P52F5K5scfVK55DT8UP4Twcebo,38627
225
226
  py2ls/translator.py,sha256=zBeq4pYZeroqw3DT-5g7uHfVqKd-EQptT6LJ-Adi8JY,34244
226
227
  py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
227
- py2ls-0.2.4.4.dist-info/METADATA,sha256=OS59HPIjSXN6Zdy5X0AxSfyvQba6SuK66h74n7nVDno,20038
228
- py2ls-0.2.4.4.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
229
- py2ls-0.2.4.4.dist-info/RECORD,,
228
+ py2ls-0.2.4.6.dist-info/METADATA,sha256=hnTtItvGoftgpulPHRrUvM-k3kQRxJHd1cOhTPWEXxk,20038
229
+ py2ls-0.2.4.6.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
230
+ py2ls-0.2.4.6.dist-info/RECORD,,