V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · Oct 22, 2020 · 1685 views
    This topic created in 2016 days ago, the information mentioned may be changed or developed.
    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 replies    2020-10-23 11:06:19 +08:00
    princelai
        1
    princelai  
       Oct 22, 2020
    你这没图我也不好瞎说,先找个图床把图贴上来,但是 pandas 绘 bar 图我都是用 party_pcts.plot(kind='bar')
    jerfoxu
        2
    jerfoxu  
    OP
       Oct 23, 2020
    @princelai 哦,这样呀!最后面我解决了!我是新建了一个文件,录入代码就好了!

    我用的是 jupyter notebook 写的代码!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2507 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 15:38 · PVG 23:38 · LAX 08:38 · JFK 11:38
    ♥ Do have faith in what you're doing.