0
votes

I have data generated from python code as such:

u, v = np.mgrid[0:2*np.pi:180*1j, 0:np.pi:90*1j]
X = np.cos(u)*np.sin(v)
Y = np.sin(u)*np.sin(v)
Z = np.cos(v)

This is written to a file tmp.dat, and I attempt to plot it in gnuplot with:

set pm3d
set palette
set hidden
splot "tmp.dat" using 1:2:3 with pm3d

However, this gives me:enter image description here It's in the general vicinity of what I want, but I'd like a smooth sphere as opposed to this. (My real data is in the same vein; with an enclosed surface I want to have transparency on.) I've tried adding set dgrid3d 50,50 to try and interpolate, however, I don't actually understand what I'm getting from this:enter image description here Any help or advice would be enormously appreciated. Changing the data to parametric (with u and v sweep data) is an option, however, I'm not certain how to do that - when I tried, the result was the same.

1
perhaps it might be relevant - how exactly do you output the X,Y,Z data into the file? One block per unique value of the z-coordinate? - ewcz
Per X value, actually. - Firnagzen

1 Answers

0
votes

Not a complete answer, but part of your problem is that "set hidden3d" is not usable here. Gnuplot has two separate subsystems for representing surfaces. One of them, controlled by "set hidden3d", tracks bounding line segments and can remove occluded portions. The other is pm3d, which uses solid-fill quadrangles rather than bounding line segments. pm3d plots do not have the option of removing occluded quadrangles, but you can get a similar effect by depth-sorting them. The relevant command is

set pm3d depthorder

This works reasonably well if the individual quadrangles are approximately square but it gives bad results for long thin quadrangles, since the two ends of the facet can have conflicting depths with regard to neighboring facets.