Pergunta

Atualmente, tenho uma matriz de matriz NX3. Eu quero plotar as três colunas como três eixos. Como eu posso fazer isso?

Eu pesquisei e as pessoas sugeriram usar Matlab, mas estou realmente tendo dificuldade em entendê -lo. Eu também preciso que seja um enredo de dispersão.

Alguém pode me ensinar?

Foi útil?

Solução

Você pode usar matplotlib por esta. Matplotlib tem um mplot3d módulo que fará exatamente o que você deseja.

from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3D
import random


fig = pyplot.figure()
ax = Axes3D(fig)

sequence_containing_x_vals = list(range(0, 100))
sequence_containing_y_vals = list(range(0, 100))
sequence_containing_z_vals = list(range(0, 100))

random.shuffle(sequence_containing_x_vals)
random.shuffle(sequence_containing_y_vals)
random.shuffle(sequence_containing_z_vals)

ax.scatter(sequence_containing_x_vals, sequence_containing_y_vals, sequence_containing_z_vals)
pyplot.show()

O código acima gera uma figura como:

matplotlib 3D image

Outras dicas

Use o seguinte código que funcionou para mim:

# Create the figure
   fig = plt.figure()
   ax = fig.add_subplot(111, projection='3d')

   # Generate the values
   x_vals = X_iso[:, 0:1]
   y_vals = X_iso[:, 1:2]
   z_vals = X_iso[:, 2:3]

   # Plot the values
   ax.scatter(x_vals, y_vals, z_vals, c = 'b', marker='o')
   ax.set_xlabel('X-axis')
   ax.set_ylabel('Y-axis')
   ax.set_zlabel('Z-axis')

   plt.show()

Enquanto x_iso é minha matriz 3D e para x_vals, y_vals, z_vals que copiei/usei 1 coluna/eixo dessa matriz e atribuída a essas variáveis/matrizes, respectivamente.

Use assíntota!

É assim que pode parecer:

http://asymptote.sourceforge.net/gallery/3d%20graphs/helix.pdf

Este é o código:http://asymptote.sourceforge.net/gallery/3d%20graphs/helix.asy

A assíntota também pode ler em arquivos de dados.

E a galeria completa:http://asymptote.sourceforge.net/gallery/

Para usar assíntota de dentro de Python:

http://www.tex.ac.uk/tex-archive/graphics/asymptote/base/asymote.py

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top