简体   繁体   English

我无法弄清楚如何在Python中为散点图散布y轴上的空间

[英]I cannot figure out how to spread out the space on the y axis for my scatterplot in Python

I entered this code with the x , y , and size defined by variables I created earlier. 我输入的代码带有xy和由前面创建的变量定义的size The problem is that the points are too bunched up and I want to stretch out my y-axis. 问题在于,这些点过于集中,我想伸展我的y轴。

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

For example, right now my y-axis goes from -0.005 to 0.04 in increments of 0.005 , how would I adjust it to count in increments of 0.0025 ? 例如,现在我的y轴以0.005增量从-0.005变为0.04 ,我如何调整它以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))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM