Matplotlib 如何更改colobar上轴的范围?

Matplotlib 如何更改colobar上轴的范围?,matplotlib,Matplotlib,我想把y限制在-5到5,而不是-200到200左右。我想我需要缩放y轴 提前谢谢 您可以通过ylim函数对y轴执行此操作 导入matplotlib.pyplot作为plt 将matplotlib.cm导入为cm x=np.random.randint(11000,大小=50) y=np.random.randint(-5,5,size=50) N=50 颜色=np.random.rand(N) plt.散射(x,y,c=颜色) plt.xlim(01000)#这是为了限制x轴 plt.ylim(

我想把y限制在-5到5,而不是-200到200左右。我想我需要缩放y轴


提前谢谢

您可以通过
ylim
函数对y轴执行此操作

导入matplotlib.pyplot作为plt
将matplotlib.cm导入为cm
x=np.random.randint(11000,大小=50)
y=np.random.randint(-5,5,size=50)
N=50
颜色=np.random.rand(N)
plt.散射(x,y,c=颜色)
plt.xlim(01000)#这是为了限制x轴
plt.ylim(-5,5)#用于限制y轴
plt.grid()