Home > other >  Matplotlib 3d plotting how to make markers smaller so object shape can be seen like a wireframe?
Matplotlib 3d plotting how to make markers smaller so object shape can be seen like a wireframe?

Time:11-24

I am trying to plot a small xyz file of a 3d object in Python. Unfortunately it's a little too thick, see below:

enter image description here

Code below is what generated it:

input_file = sys.argv[1];
print("input_file :: " str(input_file))

data = pd.read_csv(input_file, header=None)
data = data.to_numpy();

print("----- Data read successfully. Shape and random row: ------")
print(data.shape)
print(data[123,:])

fig = plt.figure()
ax = fig.add_subplot(projection='3d')
ax.scatter(data[:,0], data[:,1], data[:,2], linewidth=1)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

plt.show()

Data is of shape (316369, 3) and each row's example data looks something like: [-0.97320002 0.44980001 0.79809999]

Here's how I'd like it look, referencing one of my 3d programs:

enter image description here

Are there Matplotlib settings which would let me approach this?

CodePudding user response:

Try to change the marker and s (size) parameters of scatter:

ax.scatter(data[:,0], data[:,1], data[:,2], marker='.', s=1)

You likely have to go through trial and error to find a nice value for s (you can use decimal values). Know that it is not linear but a squared value.

CodePudding user response:

To add to @mozway's answer, setting the transparency of your markers can also help. This can be accomplished with the alpha parameter, or by specifying an RGBA color value explicitly with a <1 alpha (preferably with the color keyword argument, though c works as well).

  • Related