绘制数组时出现问题
我尝试创建一个无花果并绘制它,我做到了,我需要将结果保存为 pdf 格式,但是遇到一个问题,
import numpy as np
import sympy as sp
from sympy import *
a = np.loadtxt('hw1.txt')[0:100]
import matplotlib.pyplot as plt
fig = plt.figure('HH')
plt.title("Aikyn's first figure")
plt.plot(a)
plt.xlabel('Urazalinov')
plt.ylabel('Aikyn')
plt.show()
plt.savefig('aikyn.pdf')
我已保存但文件为空,你能告诉我出了什么问题吗 <图形尺寸 432x288,0 轴>
I tried to create a fig and plot it, I did it and I needed to save my result in pdf format, but getting an issue
import numpy as np
import sympy as sp
from sympy import *
a = np.loadtxt('hw1.txt')[0:100]
import matplotlib.pyplot as plt
fig = plt.figure('HH')
plt.title("Aikyn's first figure")
plt.plot(a)
plt.xlabel('Urazalinov')
plt.ylabel('Aikyn')
plt.show()
plt.savefig('aikyn.pdf')
I got saved but the file is empty, could u tell me what is wrong<Figure size 432x288 with 0 Axes>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在调用
plt.show()
之前调用plt.savefig()
。当您关闭由plt.show()
显示的图像时,它将从内存中释放。You should call
plt.savefig()
before callingplt.show()
. When you close the image displayed byplt.show()
, it is freed from memory.