Markers in swarmplot being replaced

486 Views Asked by At
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))

I use the above code to cycle through a combination of colors and markers for some plots. However, this messes up a seaborn swarmplot I am using by replacing the dot markers. The dataframe used in boxplot and swarmplot is this:

        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

The code is here:

# 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()

Here is the resulting graphic. I want to ensure that the dot markers are not replaced. How do I do that?

0

There are 0 best solutions below