V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
jerfoxu
V2EX  ›  Python

为什么我.plot.bar 出现的图表只显示其中的很小的一部分

  •  
  •   jerfoxu · 2020-10-22 22:00:02 +08:00 · 1151 次点击
    这是一个创建于 1275 天前的主题,其中的信息可能已经有所发展或是发生改变。
    tips = pd.read_csv('examples/tips.csv')
    party_counts = pd.crosstab(tips['day'], tips['size'])
    party_counts
    # Not many 1- and 6-person parties
    party_counts = party_counts.loc[:, 2:5]
    party_pcts = party_counts.div(party_counts.sum(1), axis=0)
    party_pcts
    party_pcts.plot.bar()

    运行后,图表部分只显示很小的一部分


    PS:这个论坛怎么上传图片呀!
    2 条回复    2020-10-23 11:06:19 +08:00
    princelai
        1
    princelai  
       2020-10-22 23:44:48 +08:00
    你这没图我也不好瞎说,先找个图床把图贴上来,但是 pandas 绘 bar 图我都是用 party_pcts.plot(kind='bar')
    jerfoxu
        2
    jerfoxu  
    OP
       2020-10-23 11:06:19 +08:00
    @princelai 哦,这样呀!最后面我解决了!我是新建了一个文件,录入代码就好了!

    我用的是 jupyter notebook 写的代码!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   933 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 20:26 · PVG 04:26 · LAX 13:26 · JFK 16:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.