我通过numpy的savetxt函数保存数据并将其提取到绘图中。当我绘制它时,脚本执行没有错误但不显示曲线 - 只有空窗口。这很奇怪,因为:
当我从另一个文件导入.txt数据时(同样使用savetxt保存),相同的脚本会生成一个很好的情节。
如果我在脚本中创建数据点,例如与arange,它的情节。
.txt数据 已加载 - 我已将其打印到屏幕上。
我检查了我的后端,它是TkAgg,互联网认为它应该是。
我的代码是
# this script makes the plots of the eigenvalue distributions for the AAS 17-225 paper
# import python modules
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
# set plot options
mpl.rcParams['xtick.major.size'] = 7
mpl.rcParams['xtick.major.width'] = 3.0
mpl.rcParams['ytick.major.size'] = 7
mpl.rcParams['ytick.major.width'] = 3.0
mpl.rcParams['axes.linewidth'] = 3.5
plt.rc('text',usetex=True)
mpl.rcParams['text.latex.preamble']=[r"\usepackage{amsmath}"]
plt.rc('font',family='serif')
plt.rc('axes',labelsize=24)
plt.rc('xtick',labelsize=24)
plt.rc('ytick',labelsize=24)
plt.rc('font',weight='bold')
plt.rc('axes',titlesize=20)
# plot method arguments
lw = 2 # linewidth
left_adj = 0.055 # left adjustment
right_adj = 0.985 # left adjustment
top_adj = 0.975 # left adjustment
bottom_adj = 0.075 # left adjustment
wspace = 0.205 # horizontal space between plots
hspace = 0.2 # verticle space between plots
n_suplot_rows = 2 # number of subplot rows
n_suplot_columns = 3 # number of subplot columns
# load data
dataDir ='/mnt/E0BA55A7BA557B4C/research/independent/recursivequats/paperCode/'
df1 = dataDir+'lamda_0p1_0p1.txt'
df2 = dataDir+'lamda_0.1_0.5.txt'
df3 = dataDir+'lamda_0.1_1.0.txt'
df4 = dataDir+'lamda_0.5_0.5.txt'
df5 = dataDir+'lamda_0.5_1.0.txt'
df6 = dataDir+'lamda_1.0_1.0.txt'
profile1 = np.loadtxt(df1)
profile2 = np.loadtxt(df2)
profile3 = np.loadtxt(df3)
profile4 = np.loadtxt(df4)
profile5 = np.loadtxt(df5)
profile6 = np.loadtxt(df6)
fig = plt.figure()
ax1 = fig.add_subplot(n_suplot_rows,n_suplot_columns,1)
p1, = ax1.plot(profile1[:,1],profile1[:,0],linewidth=lw)
ax2 = fig.add_subplot(n_suplot_rows,n_suplot_columns,2)
p1, = ax2.plot(profile2[:,1],profile2[:,0],linewidth=lw)
ax3 = fig.add_subplot(n_suplot_rows,n_suplot_columns,3)
p1, = ax3.plot(profile3[:,1],profile3[:,0],linewidth=lw)
ax4 = fig.add_subplot(n_suplot_rows,n_suplot_columns,4)
p1, = ax4.plot(profile4[:,1],profile4[:,0],linewidth=lw)
ax5 = fig.add_subplot(n_suplot_rows,n_suplot_columns,5)
p1, = ax5.plot(profile5[:,1],profile5[:,0],linewidth=lw)
ax6 = fig.add_subplot(n_suplot_rows,n_suplot_columns,6)
p1, = ax5.plot(profile6[:,1],profile6[:,0],linewidth=lw)
plt.subplots_adjust(left=left_adj,right=right_adj,top=top_adj,bottom=bottom_adj,wspace=wspace,hspace=hspace)
plt.show()
答案 0 :(得分:0)
这就是为什么工程师不应该成为艺术家......