gpt4 book ai didi

python - 我不知道如何在 Python 中分散散点图 y 轴上的空间

转载 作者:行者123 更新时间:2023-11-30 23:07:51 25 4
gpt4 key购买 nike

我使用之前创建的变量定义的 xysize 输入此代码。问题是这些点太聚集了,我想拉伸(stretch)我的 y 轴。

plt.scatter(rets.mean(),rets.std(),s = area)
plt.xlabel('Expected Return')
plt.ylabel('Risk')

例如,现在我的 y 轴从 -0.0050.04,增量为 0.005,我该如何调整它以 0.0025 为增量进行计数?

最佳答案

import matplotlib.pyplot as plt
import matplotlib.ticker as mticks

fig, ax = plt.subplots()

ax.set_ylim((-.005, .04))
ax.yaxis.set_major_locator(mticks.MultipleLocator(.0025))

enter image description here

关于python - 我不知道如何在 Python 中分散散点图 y 轴上的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32040304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com