8

I'm trying to plot using plot_trisurf, using the following code :

fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_trisurf(X1,Y1,Z1)
ax.plot_trisurf(X2,Y2,Z2)

The scale of Z1 and Z2 is different by several magnitudes.

How do I share the X and Y axis, but not the Z ?

In 2D I had the function "twinx()", but I can't find a solution for 3D.

OopsUser
  • 4,442
  • 7
  • 38
  • 64
  • Do `twinx`/`twiny` work in 3D? If they do, one possible workaround could be to pass the Z data as X or Y and then set the view and label the axes appropriately. – jdehesa Nov 01 '18 at 13:33
  • 1
    I tried something like `ax2 = ax.twinx().twiny()`, It didn't work, just got strange error. It doesn't feel like the right direction to solve the problem. – OopsUser Nov 01 '18 at 13:34
  • You may want to write function that emulates twinx but write it for the z axes since twinx/y don't work in 3D iirc. – cvanelteren Nov 01 '18 at 14:28
  • @GlobalTraveler I'm not sure how to do what you suggested... – OopsUser Nov 01 '18 at 15:00
  • The twinx/y functions add an invisible axis to the axes. In order for this to work in 3D you have to write a custom class that overwrites the rendered similar to what happens [here](https://stackoverflow.com/questions/15042129/changing-position-of-vertical-z-axis-of-3d-plot-matplotlib). – cvanelteren Nov 01 '18 at 16:31
  • It's an overkill, I hope there is a "normal" solution .. – OopsUser Nov 01 '18 at 17:10
  • Did you find a solution or did you end up overwriting the renderer? – ilke444 Mar 05 '20 at 00:32

0 Answers0