Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting two 2D plots on a 3D plot

I'm trying to map the cross-section of a laser in terms of it's energy using python. Experimentally, I'm doing this by taking manual 1D slices across the cross section which gives me data along the x and y axis separately, so that I end up with x and y data in units of millimeters and z data in energy.

I'd like to concatenate this data onto a 3D plot but I don't know how to orientate the different slivers differently.

So far I have:

fig = plt.figure(figsize = (14, 10))
ax1 = fig.add_subplot(111, projection = '3d').plot(x1, y1)
ax2 = fig.add_subplot(111, projection = '3d').plot(x2, y2)

Which give the two plots on the same axis, laying flat on the 3D plot. I'd like them both standing up right, and for x1, y1 and x2, y2 to go in different directions (i.e perpendicular to each other on the plot).

It this possible? and would anybody have any advice on how to do this?

like image 662
SkilstoPayBils Avatar asked May 02 '26 19:05

SkilstoPayBils


1 Answers

If I understood you correctly, you want first plot to be in xz plane, and the second to be in yz plane. That is possible, just fill redundant dimension of your graph with zeros:

ax = fig.add_subplot(111, projection = '3d')
ax.plot(x1, np.zeros_like(x1), y1)
ax.plot(np.zeros_like(x2), x2, y2)

This (with appropriate data) yields the following picture: enter image description here

like image 57
Andrey Sobolev Avatar answered May 05 '26 08:05

Andrey Sobolev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!