0

I am not experienced with plotting in Python. But I have managed to plot a signle distribution plot with Seaborn.

example code:

sns.displot(SD_frame_A,kind="kde")

example plot: enter image description here

So I tryed to plot three of them in one graph:

example code:

sns.displot(SD_frame_A,kind="kde")
sns.displot(SD_frame_S,kind="kde")
sns.displot(SD_frame_D,kind="kde")
plt.show()

But this will only plot the three distribution separately. Does anyone how I can plot both 3 distribution in one plot?

Thanks for reading!

0

1 Answer 1

2

You can't do that with displot because that is a figure-level function. But you can use kdeplot and provide an axes object:

ax = plt.axes()
sns.kdeplot(SD_frame_A, ax=ax)
sns.kdeplot(SD_frame_S, ax=ax)
sns.kdeplot(SD_frame_D, ax=ax)
plt.show()
Sign up to request clarification or add additional context in comments.

9 Comments

Thank you, but it returns the following error: ValueError: cannot reindex on an axis with duplicate labels
Are the frames pandas Series? Try transforming them to numpy arrays with SD_frame_A.values.
Yes they are in pandas series so I changed it to a dataframe which did not work either. I will try your option now
Sure, happy it worked!
Well it only worked for a "kdeplot", when I use the "displot" it still plots them separately. And it even becomes slower
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.