Color by Column Values in Matplotlib

后端 未结 4 1530
情话喂你
情话喂你 2020-11-28 07:50

One of my favorite aspects of using the ggplot2 library in R is the ability to easily specify aesthetics. I can quickly make a scatterplot and apply color assoc

4条回答
  •  庸人自扰
    2020-11-28 08:31

    Actually you could use ggplot for python:

    from ggplot import *
    import numpy as np
    import pandas as pd
    
    df = pd.DataFrame({'Height':np.random.randn(10),
                       'Weight':np.random.randn(10),
                       'Gender': ["Male","Male","Male","Male","Male",
                                  "Female","Female","Female","Female","Female"]})
    
    
    ggplot(aes(x='Height', y='Weight', color='Gender'), data=df)  + geom_point()
    

提交回复
热议问题