如何在python程序中使用包含特定字符的列表作为绘图标记?

如何在python程序中使用包含特定字符的列表作为绘图标记?,python,python-3.x,matplotlib,Python,Python 3.x,Matplotlib,我有4个列表,分别指向x、y、z轴和一个列表,其中包含要用作标记的字符。 打印列表时,它们都有一个列格式。3D绘图工作正常,无需添加自定义标记。 书签列表如下(在文件中): 为了绘制图,我使用了以下方法: text_style = dict(horizontalalignment='right', verticalalignment='center', fontsize=12, fontdict={'family': 'monospace'}

我有4个列表,分别指向x、y、z轴和一个列表,其中包含要用作标记的字符。 打印列表时,它们都有一个列格式。3D绘图工作正常,无需添加自定义标记。 书签列表如下(在文件中):

为了绘制图,我使用了以下方法:


    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=”如果要使用不同的标记打印点,则必须分别为每个点调用
ax.plot

for xi, yi, zi, mi in zip(x, y, z, markersS):
    ax.plot([xi], [yi], [zi], marker=mi, **marker_style)

欢迎来到SO!你能提供一个?-一个完整的玩具数据工作示例将非常有用。我收到:zs=np.broadcast_to(zs,len(xs))TypeError:type'numpy.float64'的对象没有len(),可能是因为x,y,z是float,但是markers是str?不,这意味着坐标必须是iterables(一个元素的)。请参阅编辑

    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()

for n in markersS:
    ax.plot(x,y,z,marker=n,**marker_style)
for xi, yi, zi, mi in zip(x, y, z, markersS):
    ax.plot([xi], [yi], [zi], marker=mi, **marker_style)