简体   繁体   中英

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 (ie perpendicular to each other on the plot).

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

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: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM