I am plotting some data as a 3D surface plot using Matplotlib. The code I am using is pretty similar to this 3D surface plot example. It generates the plot shown below:
The problem with this plot is that the Z-axis is not vertical. How do I make the Z-axis vertical?
I examined the different API available and found view_init. By setting a low elevation (elev=1
) of the plot using view_init
, I can get the Z-axis to be vertical, as shown below:
However, the problem here is that at low elevation the Y axis tick labels are all overwritten and cannot be viewed correctly. So I need the plot to be at a high elevation and with the X-Y plane rotation angle as shown in Figure 1. How do I achieve a vertical Z-axis for this plot?
I do not know Matlab, but I know Matplotlib is derived from the Matlab API. So, I looked at surface plot examples in Matlab documentation and found that the Z-axis seems to be vertical in their examples. One figure for illustration with high elevation is shown below:
Update 1: Based on Bentoy13's suggestion, I set view_init(elev=30, azim=-37.5)
and got the below result. It is better, but not yet vertical:
In comparison, Z-axis in Matlab plot is perfectly vertical. Also, as is visible from this angle, I cannot actually use this azim=-37.5
since some information is hidden. Any other solution? :-)