解决“jupyter导出图片怎么是空白的”

这段代码使用Python的matplotlib库创建了一个红色圆点表示的数据曲线,显示了Oreflowrate(kg/h)对Leachingrate(%)的影响。曲线的样式为ro-,线宽为2.5。代码还设置了轴标签、标题以及轴刻度参数,并将图像保存为PNG格式。
摘要由CSDN通过智能技术生成

原来代码如下:

plt.plot(x1,y1,'ro-',linewidth = 2.5,label = 'Influence curve of ore flow rate on leaching')
#标签标记位置在左下角
plt.legend(loc='upper right')
#取出图片的坐标轴
ax1 = plt.gca()
#设置图片标题,fontname设置字体,fontsize设置字号,weight设置粗体,style设置斜体
#ax1.set_title('Influence curve of ore flow rate on leaching',fontname = 'Times New Roman',fontsize = 10,weight = 'bold')
#设置x轴和y轴的标签
ax1.set_xlabel('Ore flow rate(kg/h)',fontname = 'Times New Roman',weight = 'bold')
ax1.set_ylabel('Leaching rate(%)',fontname = 'Times New Roman',weight = 'bold')
ax1.tick_params(axis='both',direction = 'in',
                color = 'blue',length = 6,width = 2)

plt.show()

plt.savefig('C:/Users/Desktop/111.png',bbox_inches = 'tight',pad_inches = 0,dpi=600)

导出之后图片如下:是空白的
请添加图片描述修改为:

plt.plot(x1,y1,'ro-',linewidth = 2.5)

#取出图片的坐标轴
ax1 = plt.gca()
#设置图片标题,fontname设置字体,fontsize设置字号,weight设置粗体,style设置斜体
#ax1.set_title('Influence curve of ore flow rate on leaching',fontname = 'Times New Roman',fontsize = 10,weight = 'bold')
#设置x轴和y轴的标签
ax1.set_xlabel('Ore flow rate(kg/h)',fontname = 'Times New Roman',weight = 'bold')
ax1.set_ylabel('Leaching rate(%)',fontname = 'Times New Roman',weight = 'bold')
ax1.tick_params(axis='both',direction = 'in',
                color = 'blue',length = 6,width = 2)

    
plt.savefig('11.png',dpi=600)
plt.show()

就可以在根目录里找到图片 然后download

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小镇躺不平家

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值