python 中ggplot画图

前几天看了下python语言中的ggplot包,尝试了下,发现跟R语言中的ggplot2包用法并没有区别,见代码如下:

from  ggplot import  * 
import pandas  as pd
import  numpy as np
test=pd.read_csv("D:\\ML_for_Hackers-master\\02-Exploration\\data\\01_heights_weights_genders.csv")
print(ggplot(test,aes(x='Height',y='Weight',color='Gender'))+geom_point())  #加颜色的散点图,以‘Gender分开’
print(ggplot(test,aes(x='Height',y='Weight',color='Gender'))+geom_point()+geom_smooth())  #加平滑效果
ggplot(test,aes(x='Height',y='Weight',color='Gender'))+geom_point()+stat_smooth(method='loess')
ggplot(test,aes(x='Height',y='Weight',color='Gender'))+geom_point()+facet_wrap('Gender',ncol=2)

#柱形图
mpg=pd.read_csv("D:\\Users\\zhoumeixu204\\Desktop\\mpg.csv")

ggplot(mpg,aes(x="hwy",y="cty",color='year'))+geom_point(color='steelblue')+scale_x_continuous(breaks=[10,20,30])   #分四段显示 [-co,10][10,20]...

ggplot(mpg,aes(x='hwy',colour='class',fill='True'))+geom_density()



ggplot(mpg,aes('class',fill='year'))+geom_bar()
ggplot(mpg,aes('class',fill='year'))+geom_bar()+ggtitle("the  hisr")


#密度曲线
ggplot(mpg,aes(x='hwy',color='class'))+geom_density()
ggplot(mpg,aes(x='hwy',colour='class',fill='True'))+geom_density()
对于不想学matplotlib的人,可以学学这个,安装很简单  easy_install  ggplot

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值