How to change 3d axis settings in matplotlib

enter image description here

I managed to create this graph using matplotlib. I would like to remove 0.2, 0.4, 0.6 .. from an axis named B and change the spacing of the axes from 200 to 100 in an axis named A. I tried to do this for quite some time ... Any suggestions?

here is the code i wrote.

from mpl_toolkits.mplot3d import Axes3D import numpy as np import matplotlib import matplotlib.pyplot as 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 irrelevant details.

+4
source share
1 answer

It is not so simple, you need to delve into objects. At first I assumed that since Axes3D is based on Axes, you can use the set_yticklabels method, but apparently this does not work. Looking in the code, you can see that the y axis is defined through w_yaxis, the 3d.YAxis axis, which in turn is ultimately based on the .Axis axis, which has the set_ticklabels method, and this worked:

 ax.w_yaxis.set_ticklabels([]) 

What do you mean "change the spacing of the axes from 200 to 100 in an axis named A"?

+3
source

All Articles