优化这段代码import matplotlib. pyplot as plt plt. plot([10, 10, 10]) plt. xlim(0, 2) plt. ylim(0, 15) plt. xlabel("I") plt. ylabel("U") ax = plt. gca() ax. spines['top']. set_visible(False) ax. spines['right']. set_visible(False) plt. show()
时间: 2023-05-30 07:06:02 浏览: 188
【python】matplotlib画图的正确姿势—只需五步,就能画出让你心动的图形
import matplotlib.pyplot as plt
x = [0, 2]
y = [0, 15]
fig, ax = plt.subplots()
ax.plot([10, 10, 10])
ax.set_xlim(x)
ax.set_ylim(y)
ax.set_xlabel("I")
ax.set_ylabel("U")
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.show()
阅读全文