4

enter image description here

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 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()
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
user926321
  • 400
  • 4
  • 13

1 Answers1

3

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"?

steabert
  • 6,540
  • 2
  • 26
  • 32
  • hey it works well, thanks!..sorry for the confusion, the second part of the question... the axis labelled "A" has 200,400,600....100, I want it as 100,200,300...1000 – user926321 Sep 25 '11 at 11:28
  • isn't it easiest in that case to just change your x data? – steabert Sep 25 '11 at 12:18
  • hmm.. no not really, this is what i really want to do.. i want to reduce the length of the axis labelled 'B'.. it has only two values [0,1], now the current interval is 0,0.2,0.4,0.6...,1 i want to change it to 0, 0.5, 1,this way the length of the axis 'B' reduces.. – user926321 Sep 25 '11 at 15:03