我有4个列表,分别指向x、y、z轴和一个列表,其中包含要用作标记的字符。 打印列表时,它们都有一个列格式。3D绘图工作正常,无需添加自定义标记。 书签列表如下(在文件<;file_icons.txt>;中):
$O$
$H$
$H$
$O$
$H$
$H$
$O$
$H$
$H$
$O$
$H$
...
data2=[]
markers=[]
with open('file_icons.txt') as file_icons:
for line in file_icons:
row = line.split()
data2.append(row[:-1])
markers.append(row[-1])
markersS = np.asarray(markers, dtype=np.str, order='C')
为了绘制图,我使用了以下方法:
text_style = dict(horizontalalignment='right', verticalalignment='center',
fontsize=12, fontdict={'family': 'monospace'})
marker_style = dict(linestyle=':', color='0.8', markersize=10,
mfc="C0", mec="C0")
fig, ax = plt.subplots()
fig.subplots_adjust(left=0.4)
marker_style.update(mec="None", markersize=5)
fig = plt.figure(1)
ax = fig.add_subplot(111, projection='3d')
ax = Axes3D(fig)
ax.plot(x,y,z,marker=markersS,**marker_style)
fig.savefig('water_confined_3d.png',dpi=100)
plt.show()
尝试运行时,出现以下错误:
ValueError:无法识别的标记样式数组([“$O$”、“$H$”、“$H$”、…、“$Mo$”、“$Mo$”、“$Mo$”],dtype=”<;U4'))
逐个尝试循环(如下所示)程序读取列表,但在每个打印点写入所有标记
for n in markersS:
ax.plot(x,y,z,marker=n,**marker_style)
我怎样才能让每个标记都写在它的特定位置?例如: 在x1、y1、z1处,标记=标记1 ... xn,yn,zn,marker=markern
如果希望使用不同的标记绘制点,则必须分别为每个点调用
ax.plot
:相关问题 更多 >
编程相关推荐