import seaborn as sns
import numpy as np # for sample data
import pandas as pd
# sample data
np.random.seed(365)
rows = 60
data1 = {'Type 1': ['a'] * rows,
'Total': np.random.normal(loc=25, scale=3, size=rows)}
data2 = {'Type 1': ['b'] * rows,
'Total': np.random.normal(loc=60, scale=7, size=rows)}
df = pd.concat([pd.DataFrame(d) for d in [data1, data2]], ignore_index=True)
# plot
plt.figure(figsize=(5, 4))
sns.violinplot(x='Type 1', y= 'Total', data=df, inner=None)
sns.swarmplot(x='Type 1', y= 'Total', data=df, color='#000000', size=3)
compared to the plot without swarmplot
Displays out to the image above, how can I change the range displayed?
I've tried changing figsize. I didn't have this issue until I overlapped the swarmplot onto the violetplot.
df
Type 1 Total
0 a 25.503763
1 a 26.570516
2 a 27.452127
3 a 30.111537
4 a 18.559157
...
115 b 67.389032
116 b 67.337122
117 b 59.193256
118 b 56.356515
119 b 57.353019


sns.swarmplot, or asns.stripplot, tosns.violinplot, the limits of the y-axis are changed.sns.catplotwithkind='violin', and.map_dataframewithsns.swarmplotalso produces the same issue, as shown in this plot.sns.swarmplotonsns.boxplot, as shown in this plot.python 3.11.2,matplotlib 3.7.1,seaborn 0.12.2Resolution
ylimvalues after plotting thesns.violinplot, and setylimto those values after plotting thesns.swarmplot.ylimto some specific value after plottingsns.swarmplotsns.swarmplotthensns.violinplot.ylimstart at the "origin", usey_bot = 0.matplotlib.pyplot.ylim,matplotlib.axes.Axes.set_ylim, andmatplotlib.axes.Axes.get_ylim.1.
2.
3.
Preferentially, use the explicit interface
plt.figureand.add_subplotplt.subplotsdf[['duration', 'kind']].head()