首页 > 其他分享 >03设置坐标轴1

03设置坐标轴1

时间:2023-01-31 20:46:58浏览次数:41  
标签:03 plt ticks y1 坐标轴 good 设置 np new

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-1,1,50)
y1 = 2*x+1
y2 = x**2

plt.figure()
plt.plot(x,y2)
plt.plot(x,y1,color='red',linewidth=1.0,linestyle='--')

#范围
plt.xlim((-1,2))
plt.ylim((-2,3))
#轴含义(标签)
plt.xlabel('X')
plt.ylabel('Y')
#更换下标
new_ticks = np.linspace(-1,2,5)
print(new_ticks)
plt.xticks(new_ticks)
plt.yticks([-2,-1.8,-1,1.22,3],
           ['really bad','bad','normal','good','realy good'])


plt.show()

image-20230131163421559

标签:03,plt,ticks,y1,坐标轴,good,设置,np,new
From: https://www.cnblogs.com/lyc2001/p/17080702.html

相关文章