python-3.x - savefig 的问题
问题描述
在我尝试编辑我的一个数字之前,我编写的用于生成箱线图的代码运行良好。现在,命令 fig.savefig (或 plt.savefig )根本不起作用。
以下代码在过去的一个月里一直在 Spyder 中运行,直到今天。我也尝试在 Jupyter Notebook 和 python raw 中运行它,但无济于事。
fig = plt.figure(1, figsize=(9, 6))
ax = fig.add_subplot(111)
d = ['D-4','D-3','D-2','D-1','D']
p = sns.boxplot(data=cdo_mom) #Plots boxplots
plt.setp(p.artists,edgecolor='k') #Changes the colors of the boxes, whiskers, median lines
plt.setp(p.lines,color='k')
p.yaxis.grid(True) #Turns on the y axis grid
p.set_axisbelow(True)
p = sns.swarmplot(data=cdo_mom,color='black') #Displays raw data
p.set(xticklabels=d) #Sets the x label as the name of the volume
plt.text(0,3.4,'n: %s' % len(cdo_mom[0]),color='blue',ha='center',va='bottom') # displays number of observations for each volume
plt.text(1,3.04,'n: %s' % len(cdo_mom[1]),color='orange',ha='center',va='bottom')
plt.text(2,3.04,'n: %s' % len(cdo_mom[2]),color='green',ha='center',va='bottom')
plt.text(3,2.9,'n: %s' % len(cdo_mom[3]),color='red',ha='center',va='bottom')
plt.text(4,3.25,'n: %s' % len(cdo_mom[4]),color='purple',ha='center',va='bottom')
plt.ylim(bottom=0)
ax.get_xticklabels()[0].set_color('red')
ax.get_xticklabels()[1].set_color('red')
ax.get_xticklabels()[2].set_color('red')
ax.get_xticklabels()[3].set_color('red')
ax.set_title('D$_0$ Median of Medians For Corrected dataset',fontsize=18)
ax.set_ylabel('D$_0$ (mm)',fontsize=16)
ax.set_xlabel('Volume',fontsize=16)
fig.savefig(r'D:\Desktop\c_mom\D0_c_mom')
plt.close()
我希望将这些数字保存在我提供的目录中,但是再次,此代码在工作一个月后意外停止工作
解决方案
推荐阅读
- algorithm - 查找向量中元素的位置
- node.js - 使用 Node、EJS 和 Firebase 的实时数据库模板
- spring - IllegalStateException:无法将“java.sql.Timestamp”类型的值转换为属性所需的“java.time.LocalDateTime”类型
- c++ - C++ 切片和虚拟析构函数
- ruby-on-rails - 如何在 Rails 的主页中使用弹性搜索表单
- angular - FormGroup 异步验证器无法正常工作
- azure - Azure 数据湖分析作业无法从数据湖存储读取数据
- angular - 问题:Visual Studio 中未安装依赖项
- nginx - Nginx proxy_cache_background_update 在源错误时清除缓存
- java - Java 类可以有多少个接口?