python - IndexError:索引 2 在文件绘图期间超出轴 1 的范围,大小为 2
问题描述
我正在尝试使用 Matplotlib 在同一个图中绘制三个文件。但是,在第三个文件中我收到了这个错误:
IndexError:索引 2 超出轴 1 的范围,大小为 2
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('classic')
k=0
InputFile = []
markers = ["o" , "s" , "D"]
colors = ["red", "green", "blue"]
for i in range(1,4):
InputFile.append("max-velocity-%s.out" %i)
for dname in InputFile:
k=k+1
data=np.loadtxt(dname, skiprows= 3)
x=data[:,1]
y=data[:,2]
plt.plot(x,y,color=colors[k-1], marker = markers[k-1])
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.xlabel(r'$t\,$(s)',fontsize=14)
plt.ylabel(r'Max Velocity',fontsize=14)
plt.show()
有人可以帮帮我吗?
谢谢。
解决方案
推荐阅读
- python - 在 tkinter 中设置错误处理循环
- dom - 我无法访问影子 dom CSS 中的插槽
- javascript - 如何将每个电子邮件地址装箱?[Javascript]
- java - 试图找到这个输入的最长回文
- selenium - Selenium 在更改到新标签时抛出奇怪的错误
- python - 如何将 Tensorflow BatchNormalization 与 GradientTape 结合使用?
- html - 需要背景 css 视频帮助
- r - 根据同一数据框中的条件生成其他行
- javascript - 尝试使用 @react-google-maps 对数组中的标记进行聚类时,this.props.children 不是一个函数
- c# - 从动态 ExpandoObject 生成 JSON 字符串