python - matplotlib 3d plot with changing labels -


so have 3d live-updating graph! shows 1 point @ time can track motion of point! here problem:

no matter seem do, point placed in center of graph , tick marks on axis change in order that. makes life difficult because don't see motion on point. here code:

from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot plt pylab import * import time import pandas pd import pickle def pickleload(picklefile):     pkl_file = open(picklefile, 'rb')     data = pickle.load(pkl_file)     pkl_file.close()     return data data = pickleload('/users/ryansaxe/desktop/kaggle_parkinsons/accelerometry/lily_dataframe') data = data.reset_index(drop=true) df = data.ix[0:,['x.mean','y.mean','z.mean','time']] ion() fig = figure() ax = fig.add_subplot(111, projection='3d') count = 0 plotting = true labels = range(-10,11) ax.set_xlabel('x label') ax.set_ylabel('y label') ax.set_zlabel('z label') ax.set_yticklabels(labels) ax.set_xticklabels(labels) ax.set_zticklabels(labels) lin = none while plotting:     df2 = df.ix[count]     count += 1     xs = df2['x.mean']     ys = df2['y.mean']     zs = df2['z.mean']     t = df2['time']     ax.set_title(t)     if lin not none:         lin.remove()     lin = ax.scatter(xs, ys, zs)      draw()     pause(0.01)     if count > 100:         plotting = false ioff() show() 

here example of data:

     x.mean    y.mean    z.mean                 time 0 -1.982905  3.395062  8.558263  2012-01-18 14:00:03 1  0.025276 -0.399172  7.404849  2012-01-18 14:00:04 2 -0.156906 -8.875595  1.925565  2012-01-18 14:00:05 3  2.643088 -8.307801  2.382624  2012-01-18 14:00:06 4  3.562265 -7.875230  2.312898  2012-01-18 14:00:07 5  4.441432 -7.907592  2.851774  2012-01-18 14:00:08 6  4.124187 -7.854146  2.727229  2012-01-18 14:00:09 7  4.199698 -8.135596  2.677706  2012-01-18 14:00:10 8  4.407856 -8.133449  2.214902  2012-01-18 14:00:11 9  4.096238 -8.453822  1.359692  2012-01-18 14:00:12 

so can make tick marks fixed point moves rather tick marks changing?

an axes3d object (your ax variable) has following methods: set_xlim, set_ylim, , set_zlim. use these fix limits of axes.

documentation:

edit

using set_xlim, etc, works me. here code:

#!python2  mpl_toolkits.mplot3d import axes3d pylab import *  data = [     [-1.982905,  3.395062,  8.558263,  '2012-01-18 14:00:03'],     [ 0.025276, -0.399172,  7.404849,  '2012-01-18 14:00:04'],     [-0.156906, -8.875595,  1.925565,  '2012-01-18 14:00:05'],     [ 2.643088, -8.307801,  2.382624,  '2012-01-18 14:00:06'],     [3.562265, -7.875230,  2.312898,  '2012-01-18 14:00:07'],     [4.441432, -7.907592,  2.851774,  '2012-01-18 14:00:08'],     [4.124187, -7.854146,  2.727229,  '2012-01-18 14:00:09'],     [4.199698, -8.135596,  2.677706,  '2012-01-18 14:00:10'],     [4.407856, -8.133449,  2.214902,  '2012-01-18 14:00:11'],     [4.096238, -8.453822,  1.359692,  '2012-01-18 14:00:12'], ]  ion() fig = figure() ax = fig.add_subplot(111, projection='3d') ax.set_xlabel('x label') ax.set_ylabel('y label') ax.set_zlabel('z label') ax.set_xlim((-10, 11)) ax.set_ylim((-10, 11)) ax.set_zlim((-10, 11))  lin = none x, y, z, t in data:     ax.set_title(t)     if lin not none:         lin.remove()     lin = ax.scatter(x, y, z)     draw()     pause(0.1)  ioff() show() 

edit 2

you have @ switching off autoscaling of axes on default. maybe overriding set_lim methods.

documentation:


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -