import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-1,1,5)
y = x+1
plt.xlim((-1,6))
new_ticks = np.linspace(-1,2,5)
plt.xticks(new_ticks)
plt.plot(x,y,'ob-')
plt.show()

matplotlib之np.linspace、plt.xlim和xticks
改变xticks——坐标轴显示和精度

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-1,1,5)
y = x+1
plt.xlim((-1,6))
new_ticks = np.linspace(-1,6,10)
plt.xticks(new_ticks)
plt.plot(x,y,'ob-')
plt.show()

matplotlib之np.linspace、plt.xlim和xticks

改变linspace

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-1,1,100)
y = x+1
plt.xlim((-1,6))
new_ticks = np.linspace(-1,6,10)
plt.xticks(new_ticks)
plt.plot(x,y,'ob-')
plt.show()

matplotlib之np.linspace、plt.xlim和xticks
改变xlim——改变x轴的取值范围

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-1,1,100)
y = x+1
plt.xlim((-1,7))
new_ticks = np.linspace(-1,6,10)
plt.xticks(new_ticks)
plt.plot(x,y,'ob-')
plt.show()

matplotlib之np.linspace、plt.xlim和xticks

相关文章:

  • 2021-05-07
  • 2022-12-23
  • 2021-07-30
  • 2021-12-04
  • 2021-04-05
  • 2022-01-21
  • 2021-05-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案