How can I overlay two graphs in Seaborn?

后端 未结 4 1945
梦谈多话
梦谈多话 2020-11-27 17:59

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.

4条回答
  •  感动是毒
    2020-11-27 18:44

    The data is about Private vs Public collage data but works, as we can see we load all the global parameters to a seaborn object and later we map the charts to the same pane.

    import seaborn as sns
    
    import matplotlib.pyplot as plt
    
    import pandas as pd
    
    
    df = pd.read_csv('College_Data',index_col=0)
    
    g = sns.FacetGrid(df,hue='Private',palette='coolwarm',size=6,aspect=2)
    
    g.map(plt.hist,'Outstate',bins=20,alpha=0.7)
    

    See Chart

提交回复
热议问题