【发布时间】:2020-05-12 11:09:37
【问题描述】:
【问题讨论】:
标签: python python-3.x numpy matplotlib
【问题讨论】:
标签: python python-3.x numpy matplotlib
请在x和y中插入“精确”值
import matplotlib.pyplot as plt
# data, the length of the two lists MUST be the same
x = [0, 6, 10, 15, 17, 26, 28]
y = [0, 20, 20, 30, 30, 0, 0]
# plot the data
plt.plot(x,y)
# modify the ticks to show directly the values
plt.xticks(x)
plt.yticks(sorted(set(y)))
# make a grid
plt.grid(1)
# tell matplotlib "we are done, please show what we have prepared"
plt.show()
【讨论】:
很难从图像中读取准确值;您必须自己输入正确的值。如果您有任何问题,请随时提出。
import matplotlib.pyplot as plt
x = [0, 6, 10, 15, 22, 26]
y = [0, 22, 22, 27.5, 27.5, 0]
# optional; making the y axis go up to 45
axes = plt.gca()
axes.set_ylim([0, 45])
plt.plot(x,y)
plt.show()
【讨论】: