Python使用R的ggplot

"""
module prequsites:
statsmodels installed by wheel
matplotlib
pandas
numpy
scipy
"""
from ggplot import *
import pandas as pd
# Error
# 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

df=pd.read_excel(r"C:\Users\anddyhua\Desktop\data.xlsx")
# Warning
"""
FutureWarning: pandas.tslib is deprecated and will be removed in a future version.
You can access Timestamp as pandas.Timestamp
  pd.tslib.Timestamp
"""
# Error
"""
ImportError: cannot import name 'Timestamp' from 'pandas.lib'
"""
#print(df.head())
#meat_lng = pd.melt(meat[['date','beef','pork','broilers']],id_vars='Item_Type')


p=ggplot(df, aes(x='Item_Visibility', y='Item_MRP',color ='factor(Item_Type)')) + \
    geom_point(size=10) + scale_x_continuous(name='Item Visibility', breaks = [i/100 for i in range(0,40,5)] ) + \
    scale_y_continuous(name='Item MRP', breaks = range(0,270,30))+ theme_bw() + labs(title="Scatterplot") + \
    facet_wrap(x='Item_Type')
#print (p)
#zoom in the plot image
p.save("data.png",height=15,width=20)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值