Axes3D:adjusting the parameters of the plot

Dear Friends, i used the following code to create a 3D plot (attached figure). I manipulate the appearance of the graph. Someone please enlighten me on the same. I dnt get what functions should i use to do the following manipulations.

  1. How to remove the blue shading in the grid
  2. How to change the distance between the axis label and axis tick labels
  3. How to set the interval of the axis ticks. For example the xlim varies from -80 to 60. I want to set xticks at an interval of 30 rather than 20 as in the plot.

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

FIG=plt.figure(figsize=(4.,3.27),dpi=200)
ax = Axes3D(FIG,azim=-60,elev=15)

x=np.reshape(np.loadtxt(data[0]),15000)
y=np.reshape(np.loadtxt(data[1]),15000)
z=np.reshape(np.loadtxt(data[2]),15000)
ax.scatter3D(x[::10],y[::10],z[::10],edgecolors=col[i],facecolors=‘white’,marker=mar[i],s=5,alpha=0.7)
ax.set_xlabel(‘PC1’,size=8)
ax.set_ylabel(‘PC2’,size=8)
ax.set_zlabel(‘PC3’,size=8)
ax.set_xlim3d(-80,60,30)
ax.set_ylim3d(-40,50,30)
ax.set_zlim3d(-40,40,30)

test.png

Friends,
I sent the following mail to mpl users with a figure. Since the size was bigger, it bounced back to my email. So i am fwd it again without attaching the figure.

It seems that i can only set tick labels and limits of the axes using set_xlabel and set_xlim3d functions.Basically i want to know how to manipulate the x,y and z ticks intervals for a graph created with Axes3D.

···

On Fri, Jan 14, 2011 at 12:06 PM, Bala subramanian <bala.biophysics@…287…> wrote:

Dear Friends, i used the following code to create a 3D plot (attached figure). I manipulate the appearance of the graph. Someone please enlighten me on the same. I dnt get what functions should i use to do the following manipulations.

  1. How to remove the blue shading in the grid
  2. How to change the distance between the axis label and axis tick labels
  3. How to set the interval of the axis ticks. For example the xlim varies from -80 to 60. I want to set xticks at an interval of 30 rather than 20 as in the plot.

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

FIG=plt.figure(figsize=(4.,3.27),dpi=200)
ax = Axes3D(FIG,azim=-60,elev=15)

x=np.reshape(np.loadtxt(data[0]),15000)
y=np.reshape(np.loadtxt(data[1]),15000)
z=np.reshape(np.loadtxt(data[2]),15000)
ax.scatter3D(x[::10],y[::10],z[::10],edgecolors=col[i],facecolors=‘white’,marker=mar[i],s=5,alpha=0.7)

ax.set_xlabel(‘PC1’,size=8)
ax.set_ylabel(‘PC2’,size=8)
ax.set_zlabel(‘PC3’,size=8)
ax.set_xlim3d(-80,60,30)
ax.set_ylim3d(-40,50,30)
ax.set_zlim3d(-40,40,30)

Dear Friends, i used the following code to create a 3D plot (attached figure). I manipulate the appearance of the graph. Someone please enlighten me on the same. I dnt get what functions should i use to do the following manipulations.

  1. How to remove the blue shading in the grid
  2. How to change the distance between the axis label and axis tick labels

Unfortunately, this is not possible to do with the current version of matplotlib. I have been working on making this (somewhat) possible in the next release. One thing you can do to make the axes labels look “better” is to trigger mplot3d’s internal logic to rotate the labels to be parallel to the axes. mplot3d automatically rotates labels that have more than 4 characters in them. So, if you want “PC1” to be rotated, set the axis label to " PC1 " with spaces so that it will have 5 characters and get rotated.

  1. How to set the interval of the axis ticks. For example the xlim varies from -80 to 60. I want to set xticks at an interval of 30 rather than 20 as in the plot.

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

FIG=plt.figure(figsize=(4.,3.27),dpi=200)
ax = Axes3D(FIG,azim=-60,elev=15)

x=np.reshape(np.loadtxt(data[0]),15000)
y=np.reshape(np.loadtxt(data[1]),15000)
z=np.reshape(np.loadtxt(data[2]),15000)
ax.scatter3D(x[::10],y[::10],z[::10],edgecolors=col[i],facecolors=‘white’,marker=mar[i],s=5,alpha=0.7)

ax.set_xlabel(‘PC1’,size=8)
ax.set_ylabel(‘PC2’,size=8)
ax.set_zlabel(‘PC3’,size=8)
ax.set_xlim3d(-80,60,30)
ax.set_ylim3d(-40,50,30)
ax.set_zlim3d(-40,40,30)

Passing ‘30’ to set_xlim to set the tick intervals is not a feature in both regular 2d plotting and 3d plotting, so I don’t know how you expected that to work. If you want to manually control the axis ticks, you can use axis locators just like for 2D plots, keeping in mind that the axis objects for 3d plots are ax.w_xaxis, ax.w_yaxis, and ax.w_zaxis (where for a 2d plot, it would be ax.xaxis, ax.yaxis, ax.zaxis).

I hope this helps!
Ben Root

···

On Fri, Jan 14, 2011 at 5:06 AM, Bala subramanian <bala.biophysics@…287…> wrote: