Вопрос

While plotting a list in pylab or mplot3d (2d or 3d scatter plot), is it possible to use the index in the list as marker? Or other ways (or other libraries) that can make the viewer understand which point in the list corresponds to which point on the graph.

I've included a 3d scatter plot here just for reference. I was hoping to change the blue dot marker to the index in the list. 3d scatter plot

Это было полезно?

Решение

Sure, you'll just need to make separate plot calls for each point.

However, because each point will have a different marker, things will render rather slowly. If you have several thousand points, this is probably a bad idea. However, at that point, you wouldn't be able to see the numbers, anyway.

As an example:

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

num = 30
t = np.linspace(0, 10*np.pi, num)
x, y = np.cos(t), np.sin(t)

fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
for i in range(num):
    ax.plot([x[i]], [y[i]], [t[i]], marker='${}$'.format(i),
            markersize=12, color='black')
plt.show()

enter image description here

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top