python - How to use seaborn pointplot and violinplot in the same figure? (change xticks and marker of pointplot) -
i trying create violinplots shows confidence intervals mean. thought easy way plot pointplot on top of violinplot, not working since seem using different indices xaxis in example:
import matplotlib.pyplot plt import seaborn sns titanic = sns.load_dataset("titanic") titanic.dropna(inplace=true) fig, (ax1,ax2,ax3) = plt.subplots(1,3, sharey=true, figsize=(12,4)) #ax1 sns.pointplot("who", "age", data=titanic, join=false,n_boot=10, ax=ax1) #ax2 sns.violinplot(titanic.age, groupby=titanic.who, ax=ax2) #ax3 sns.pointplot("who", "age", data=titanic, join=false, n_boot=10, ax=ax3) sns.violinplot(titanic.age, groupby=titanic.who, ax=ax3) ax3.set_xlim([-0.5,4])
print(ax1.get_xticks(), ax2.get_xticks())
gives: [0 1 2] [1 2 3]
why these plots not assigning same xtick numbers 'who'-variable , there way can change this?
i wonder if there anyway can change marker pointplot, because can see in figure, point big covers entire confidence interval. horizontal line if possible.
violinplot
takes positions
argument can use put violins somewhere else (they inherit default matplotlib boxplot positions).
pointplot
takes markers
argument can use change how point estimate rendered.
Comments
Post a Comment