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
QGabriel
V2EX  ›  Python

matplotlib 问题

  •  
  •   QGabriel · 2021-09-06 15:55:46 +08:00 · 1043 次点击
    这是一个创建于 954 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Y 轴必须从 0 开始吗?
    我的需求是 Y 轴 2507 至 2991 区间, 间隔值为 53
    xo = np.linspace(2507, 2991, 53)
    plt.yticks(xo)
    plt.show()

    这样之后数据都显示在最上方,数字都重叠在一起了.
    求大佬指点一下
    2 条回复    2021-09-06 17:04:42 +08:00
    ruxuan1306
        1
    ruxuan1306  
       2021-09-06 16:38:25 +08:00
    ```python
    import numpy as np
    import matplotlib.pyplot as plt

    fig = plt.figure()
    ax = fig.add_subplot()

    ax.set_yticks(np.linspace(2507, 2991, 53))
    ax.set_ylim(2507, 2991)

    x = np.random.randint(2507, 2991, (10,))
    y = x

    ax.scatter(x, y)
    fig.show()
    ```
    QGabriel
        2
    QGabriel  
    OP
       2021-09-06 17:04:42 +08:00
    @ruxuan1306 大佬 我这怎么运行不了呢...小火箭弹出来就关闭了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5944 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 06:17 · PVG 14:17 · LAX 23:17 · JFK 02:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.