Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

python - How can I overlay two graphs in Seaborn?

How can I overlay two graphs in Seaborn? I have two columns in my data I would like to have them in the same graph. How can I do it preserving the labeling for both graphs.

question from:https://stackoverflow.com/questions/32899463/how-can-i-overlay-two-graphs-in-seaborn

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

seaborn function that operate on a single Axes can take one as an argument.

For instance, the docs to seaborn.kdeplot include:

ax : matplotlib axis, optional
    Axis to plot on, otherwise uses current axis

So if you did:

df = function_to_load_my_data()
fig, ax = plt.subplots()

You could then do:

seaborn.kdeplot(df['col1'], ax=ax)
seaborn.kdeplot(df['col2'], ax=ax)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...