0

So, I need to plot some data in a nice 3D plot. After using a few libraries for 3D plotting I get the best plot for my data using plotly, and that looks like this enter image description here
This is exactly the plot I need. But the free version of plotly only let you save the plot in png or jpeg and doesn't export to vector graphics formats like svg or eps that I need. So, I moved to another popular library i.e. python matplotlib. Using this script,

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt


fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# some calculations here

ax.plot_surface(x, y, z, cmap='coolwarm', rstride=5,
                cstride=10, vmin=-1.65447, vmax=-1.4)
ax.set_zlim(-1.65447, -1.4)
plt.show()

This gives me the plot enter image description here

Now, this looks totally messed up and ugly. The biggest problem here is that the Z axis doesn't get cut at -1.4. I don't have deeper knowledge about matplotlib, so I don't know how to fix this. So, how to make the plot better and more like the nice plolty plot I want.

Community
  • 1
  • 1
Eular
  • 1,707
  • 4
  • 26
  • 50
  • You'll be more likely to get an answer if you provide an [mcve]. – Craig Apr 13 '19 at 18:15
  • You can cut the data lower 1.4 by setting it to nan – cvanelteren Apr 13 '19 at 22:07
  • Matplotlib isn't really great for 3D data visualisations. See its own FAQ [here](https://matplotlib.org/mpl_toolkits/mplot3d/faq.html) and a good answer to a very relatable queston [here](https://stackoverflow.com/a/43004221/565489). I'd also suggest to use mayavi instead. – Asmus Apr 13 '19 at 22:12

0 Answers0