0

Hi I have a text file containing three columns of numbers; one column each for the x,y,z coordinates of a bunch of points. All numbers are between 0 ad 1.

I want to plot all these points in the unit cube [0,1]x[0,1]x[0,1].

Please let me know how I can do this in Octave or MatPlot lib, whichever prduces a better quality image.

1 Answer 1

3

If I understand your question correctly, this is how it looks in Matplotlib:

3D scatter plot

This is the code to produce this plot:

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

np.random.seed(101)
x,y,z = np.random.rand(3,20)

fig = plt.figure()
# version 1.0.x syntax:
#ax = fig.add_subplot(111, projection='3d')
# version 0.99.x syntax: (accepted by 1.0.x as well)
ax = Axes3D(fig)

ax.scatter(x,y,z)

fig.savefig('scatter3d.png')

As the code suggests, there are slight differences in how matplotlib version 0.99.1.1 and version 1.0.1 behave, as noted in this SO question/answer. I am using 0.99.1.1, and I had trouble using all the options available to 2D scatter plots, which should be the same for 3D plots as well. The full list of scatter features are listed here.

The above code resulted from looking at the matplotlib tutorial on 3D plotting.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.