0

I have two dataframes of equal size. I would like to plot the distribution of the data on a boxplot or violin plot as a pair. Thus far I was able to plot them, however, the distributions are top of each other. How can I plot them next to each other?

fig, ax = plt.subplots(figsize=(15, 6))
ax = sns.violinplot(data=dfInside, color="blue")
ax = sns.violinplot(data=dfOutside, color="red")
plt.show()

My current result: enter image description here

Lamech
  • 23
  • 2
  • 8
  • A better way would be to use two plots like stack or on side. Since the data are in two dataframe. Make two subplots and stack them and draw the plot respectively. More info on https://matplotlib.org/devdocs/gallery/subplots_axes_and_figures/subplots_demo.html – sharmajee499 Sep 18 '20 at 11:45
  • Thanks. I managed. I solved it by merging the two data frames. Creating a key, which I provided hue="key" in the seaborn plot. This solved the issue. Ps I also had to restructure the data. – Lamech Sep 18 '20 at 14:16

1 Answers1

1

I solved it by merging the two data frames. Creating a key, which I provided hue="key" in the seaborn plot. This solved the issue. Ps I also had to restructure the data.

Lamech
  • 23
  • 2
  • 8