Python:Matplotlib imshow shift xlabel数字

2024-10-01 17:30:45 发布

您现在位置:Python中文网/ 问答频道 /正文

是否可以移动x轴和y轴的标签号,例如+2?例如,我创建了此图像,但我希望标签编号以2开头:

enter image description here

我的密码是:

jacaardMatrix = 1.662887377173091485e-01    3.432835820895522305e-01    3.568320278503046006e-01
5.065963060686015651e-02    3.160270880361173984e-01    3.374888691006233121e-01
3.093987157034442520e-02    1.802120141342756221e-01    1.748178980228928259e-01


fig2=plt.figure()  
plt.title("Radius and FRC Jacaard Values for Scoring System: "+str(i))
plt.xlabel('Radius')
plt.ylabel('FRC Size')
plt.imshow(jacaardMatrix)

Tags: and图像密码fortitleplt标签编号
2条回答

我相信你能做到

import mathplotlib.pyplot as p
plt.xticks(np.arange(-0.5, 3, 0.5), np.arange(2, 5.5, 0.5))

请参见示例this。感谢重要的Beingernest的评论。在

您可以使用imshowextent参数来设置绘图的比例。从2到5使用

plt.imshow(jacaardMatrix, extent=[2,5,2,5])

其中前两个数字表示x范围,后两个数字表示y范围。在

相关问题 更多 >

    热门问题