2024-09-30 22:10:14 发布
网友
我正在为python使用vscdoe。当我这样做时:
from matplotlib import pyplot fig, ax = pyplot.subplots()
它会给我一个空白的情节。然而,当我使用
ax.plot([1, 2, 3], [1, 4, 6])
在随后的街区,我得到了一个
<matplotlib.lines.Line2D at 0x7f9f118e68b0>
我的问题是:如何让vscode打印我的绘图? 谢谢
您忘记添加^{}:
from matplotlib import pyplot fig, ax = pyplot.subplots() ax.plot([1, 2, 3], [1, 4, 6]) pyplot.show()
输出:
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 4, 6]) plt.show()
您需要立即使用plt.show(),因为您没有打印任何图形
plt.show()
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 4, 6]) plt.show() # this line displays your graph
现在您已经知道如何打印图形,可以添加标题和轴标签
plt.ylabel('some numbers') # y-axis title plt.xlabel('other numbers') # x-axis title plt.title('My Graph') # main title plt.show()
您忘记添加^{} :
输出:
您需要立即使用
plt.show()
,因为您没有打印任何图形示例:
自定义图形
现在您已经知道如何打印图形,可以添加标题和轴标签
输出
相关问题 更多 >
编程相关推荐