python - label manipulation for 3d plot using matplotlib -


I came up with the following code to create a shape in Python + matplotlib:

 < code> 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 range (3): ax.plot (KX [x_points ] Markum_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] $ ')  

Output is:

My question is, how can i

  1. move the z axis label and the label in the left hand They can mark the side of the figure, so that they are not overwritten by the rings and
  2. Increase the space between the labels of X and Y tick labels and axes (note they are specially for the Y axis Overlap).
  3. You can snap to Zaxis on the left with the code you posted: < / p>

      Tmp_plans = AKS Kzksisk_plans Akskzksisk_plans = (Tmp_plans [2], Tmp_plans [3], Tmp_plans [0], Tmp_plans [1], Tmp_plans [4], Tmp_plans [ 5]) view_1 = (25, -135) view_2 = (25, -45) init_view = view_2 ax.view_init (* init_view)  

    You can control the distance of the label of the axis , By adding a new line and linepacing :

      ax.set_xlabel ('\ n' + 'xlabel', linespacing = 4)  

    Here's a full example:

      #! / Usr / bin / python3 import matplotlib.pyplot as NP X = np.arange (-5, 5, 0.25) Y = NP as mpl_toolkits.mplot3d import Axes3D as numpy import plt. Archange (-5, 5, 0.25) X, Y = NP. Mesegrid (x, y) R = NP Skyuarti (x ** 2 + y ** 2) Z = Anpiksin (R) fig = Pieltikfigyur () AX = Anjir.ad_sbplot (111, projection = '3D' ) Tmp_plans = Akskzksisk_plans Akskzksisk_plans = (Tmp_plans [2], Tmp_plans [3], Tmp_plans [0], Tmp_plans [1], Tmp_plans [4], Tmp_plans [5]) Wu_l = (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', linepacing = 4) ax. Set_ylabel ('ylabel') fig.tight_layout () fig.savefig ('test.png')  

    (note B However zx and are on the wrong side of the zy grid box. I do not know how to fix it).


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -