I came up with the following code to produce a figure in python+matplotlib:
fig = plt.figure(figsize=(10,8))
ax = fig.add_subplot(1,1,1, projection='3d')
ax.plot_surface(KX[kxl3d:kxr3d,kxl3d:kxr3d], KY[kxl3d:kxr3d,kxl3d:kxr3d],
BLP[kxl3d:kxr3d,kxl3d:kxr3d], rstride=8, cstride=8, alpha=0.4)
for idx in range(3):
ax.plot(kx[x_points]+momentum_spi[idx,0], ky[y_points]+momentum_spi[idx,1],
energy_spi[idx], linestyle='none', marker='o',
markerfacecolor=color_spi[idx], markersize=5)
ax.set_xlim(kl3d, kr3d)
ax.set_ylim(kl3d, kr3d)
ax.set_xlabel(r'$k_x[\mu m^{-1}]$')
ax.set_ylabel(r'$k_y[\mu m^{-1}]$')
ax.set_zlabel(r'$\epsilon-\omega_X[\gamma_p]$')
The output is:
My question is, how can I
You can snap zaxis to the left with the code posted here:
tmp_planes = ax.zaxis._PLANES
ax.zaxis._PLANES = ( tmp_planes[2], tmp_planes[3],
tmp_planes[0], tmp_planes[1],
tmp_planes[4], tmp_planes[5])
view_1 = (25, -135)
view_2 = (25, -45)
init_view = view_2
ax.view_init(*init_view)
You can control the distance of label to the axis, by adding a new line, and setting linespacing
:
ax.set_xlabel('\n' + 'xlabel', linespacing=4)
Here's a complete example:
#!/usr/bin/python3
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
tmp_planes = ax.zaxis._PLANES
ax.zaxis._PLANES = ( tmp_planes[2], tmp_planes[3],
tmp_planes[0], tmp_planes[1],
tmp_planes[4], tmp_planes[5])
view_1 = (25, -135)
view_2 = (25, -45)
init_view = view_2
ax.view_init(*init_view)
ax.plot_surface(X, Y, Z)
ax.set_xlabel('\n' + 'xlabel', linespacing=4)
ax.set_ylabel('ylabel')
fig.tight_layout()
fig.savefig('test.png')
(Note though that the zx and zy grid goes on the wrong side of the box. I don't know how to fix that).
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