python ggplot_Python中的ggplot样式

When I look at the plotting style in the Pandas documentation, the plots look different from the default one. It seems to mimic the ggplot "look and feel".

Same thing with the seaborn's package.

How can I load that style? (even if I am not using a notebook?)

解决方案

Update: If you have matplotlib >= 1.4, there is a new style module which has a ggplot style by default. To activate this, use:

from matplotlib import pyplot as plt

plt.style.use('ggplot')

This is recommended above the styling through the pandas options as explained below (and is also used in the pandas docs now).

For pandas, use:

pd.options.display.mpl_style = 'default'

and this will give you the 'ggplot-like' style for matplotlib figures (Note that the name is a bit confusing as this is not enabled by default, and this should actually be added to the docs).

For seaborn, as Paul H commented, it is enough to import seaborn

By the way, if you really want something like ggplot in python with ggplot syntax (and not only ggplot-like style), there is also a python ggplot library based on pandas: https://github.com/yhat/ggplot/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值