1
import palettable
bmap = palettable.tableau.Tableau_20.mpl_colors

all_markers = ['s', 'o', '^', '*', 'v'] * 100

max_values = len(bmap) if len(bmap) < len(all_markers) else len(all_markers)

# Make sure equal number of cycle elements for color and markers
markers = all_markers[:max_values]
bmap = bmap[:max_values]

color_cycle = cycler('color', bmap)  # color cycle
marker_cycle = cycler('marker', markers)  # marker cycle

plt.rc('axes', prop_cycle=(color_cycle + marker_cycle))

我使用上面的代码循环显示某些绘图的颜色和标记组合。但是,这会通过替换点标记来搞乱我正在使用的 seaborn swarmplot。boxplot 和 swarmplot 中使用的数据框是这样的:

        Poor     Watch  Favourable  Exceptional
0   0.256667  0.186000    0.100667     0.456667
1   0.259333  0.150000    0.181333     0.409333
2   0.360000  0.200667    0.158667     0.280667
3   0.380667  0.217333    0.109333     0.292667
4   0.258667  0.141333    0.150667     0.449333
5   0.210000  0.146000    0.167333     0.476667
6   0.794667  0.052000    0.056000     0.097333
7   0.269333  0.157333    0.112000     0.461333
8   0.338667  0.230667    0.119333     0.311333
9   0.716000  0.092000    0.084000     0.108000
10  0.627333  0.103333    0.124000     0.145333
11  0.332667  0.171333    0.098667     0.397333
12  0.331333  0.210000    0.122667     0.336000
13  0.417333  0.164667    0.108000     0.310000

代码在这里:

# Copy the data above
import pandas
import matplotlib.pyplt as plt
import seaborn as sns
df = pandas.read_clipboard()
ax = sns.boxplot(data=df, linewidth=1.5, width=0.25)
# stackoverflow.com/questions/34163622/seaborn-passes-kwargs-to-plt-boxplot
plt.setp(ax.artists, alpha=.3, fill=False)
ax = sns.swarmplot(data=df, color='.25')
plt.setp(ax.artists, alpha=.6)

ax.set_ylabel('Class probability')
ax.set(ylim=(0, 1.0))

plt.tight_layout()
plt.show()

这是生成的图形。我想确保不替换点标记。我怎么做?

4

0 回答 0