1

I have the following data as example

Names   Static  Dynamic
La  0.1 0.7
Li  0.2 0.02
Sa  0.3 0.044
Pa  0.4 0.444
D   0.7 0.1

my desire is to draw a combined histogram like this one Histogram

any help will be much appreciated

1 Answer 1

2

You can pd.melt setting Names as id_vars and use seaborn's sns.catplot:

import pandas as pd
import seaborn as sns

sns.catplot(data=(pd.melt(df, id_vars='Names')
                    .rename(columns={'variable':'x-axis', 'value':'y-axis'})),
            x='x-axis', 
            y='y-axis', 
            hue='Names', 
            kind='bar',
            height=6,
            aspect=1.5)

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

Fantastic @yatu, Thank you
i got good results, but i am trying to change the names of the x and y axes it gives me errors
how to do that?
Updated @christina
Thank you a lot @yatu, Very useful answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.