How to change the 3d axis settings in matplotlib
I have managed to create this graph using matplotlib. I would like to remove the 0.2, 0.4, 0.6.. from the axis named B and change the axis interval from 200 to 100 in the axis named A. I have been trying to do this for quite sometime now...Any suggestions??
here is the code I have written.
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib
import matplotlib.pyplot as开发者_如何学JAVA plt
f_attributes=open("continuous.data","r")
x=[]
y=[]
spam=[]
count=1
skew=[]
fig = plt.figure()
ax = Axes3D(fig)
total=[]
while count<=1024:
attributes=f_attributes.readline()
attributes=attributes.replace(".\n","")
attributes=attributes.split(',')
classification=int(attributes[10].replace(".\n",""))
if float(attributes[8]) >=0:
skew.append(float(attributes[8]))
x.append(count)
y.append(classification)
if classification == 0:
ax.scatter(x, y, skew, c='g', marker='o')
else:
ax.scatter(x, y, skew, c='r', marker='o')
x=[]
y=[]
skew=[]
count+=1
ax.set_xlabel('A')
ax.set_ylabel('B')
ax.set_zlabel('C')
plt.show()
Please ignore the irrelevant details..
This isn't so easy actually, you have to delve into the objects. I first assumed since Axes3D is based on Axes, you could use the set_yticklabels
method, but apparently that doesn't work. Looking in the code, you can see that the y axis is set through w_yaxis, an axis3d.YAxis, which in turn is eventually based on axis.Axis which has the set_ticklabels
method, and this worked:
ax.w_yaxis.set_ticklabels([])
What do you mean with "change the axis interval from 200 to 100 in the axis named A"?
精彩评论