I am making this 3D plot using matplotlib:
ax.plot_surface(x_surf, y_surf, np.reshape(npp, (max_temp/step, max_temp/step)), linewidth=0.2,cmap=palettable.colorbrewer.sequential.Greens_9.mpl_colormap)
How can I make the axis label and axis names look more like this plot:
Rotate X-Axis Tick Labels in Matplotlib There are two ways to go about it - change it on the Figure-level using plt. xticks() or change it on an Axes-level by using tick. set_rotation() individually, or even by using ax. set_xticklabels() and ax.
With matplotlib version 3.3. 0, the matplotlib functions set_xlabel and set_ylabel have a new parameter “loc” that can help adjust the positions of axis labels. For the x-axis label, it supports the values 'left', 'center', or 'right' to place the label towards left/center/right.
Set xticks and yticks label rotation at 90 degrees by using plt. xticks() and plt. yticks() method for the x-axis and y-axis respectively and set rotation= 90 as the argument in the method. In last, display the figure by using the plt.
As far as I understood, you want change the "axis label" and "axis names".
Unfortunately I could only do part of it (I hope that's something new to you and that someone else finds the second part of it):
I did some changes in http://matplotlib.org/examples/mplot3d/pathpatch3d_demo.html in order to obtain the images above
import matplotlib.pyplot as plt
from matplotlib.patches import Circle, PathPatch
# register Axes3D class with matplotlib by importing Axes3D
from mpl_toolkits.mplot3d import Axes3D
import mpl_toolkits.mplot3d.art3d as art3d
from matplotlib.text import TextPath
from matplotlib.transforms import Affine2D
def text3d(ax, xyz, s, zdir="z", size=None, angle=0, usetex=False, **kwargs):
x, y, z = xyz
if zdir == "y":
xy1, z1 = (x, z), y
elif zdir == "y":
xy1, z1 = (y, z), x
else:
xy1, z1 = (x, y), z
text_path = TextPath((0, 0), s, size=size, usetex=usetex)
trans = Affine2D().rotate(angle).translate(xy1[0], xy1[1])
p1 = PathPatch(trans.transform_path(text_path), **kwargs)
ax.add_patch(p1)
art3d.pathpatch_2d_to_3d(p1, z=z1, zdir=zdir)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.tick_params(axis='x',direction='out', length=6, width=2, colors='r')
text3d(ax, (4, -2, 0), "X-axis", zdir="z", size=.5, usetex=False,
ec="none", fc="k")
text3d(ax, (12, 4, 0), "Y-axis", zdir="z", size=.5, usetex=False,
angle=.5*3.14159, ec="none", fc="k")
text3d(ax, (12, 10, 4), "Z-axis", zdir="y", size=.5, usetex=False,
angle=.5*3.14159, ec="none", fc="k")
ax.set_xlim3d(0, 10)
ax.set_ylim3d(0, 10)
ax.set_zlim3d(0, 10)
plt.show()
I was expecting to find how to develop the second part of this problem at http://matplotlib.org/api/axes_api.html, but I did not find it yet.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With