Saturday 15 June 2013

python - How to control individual matplotlib subplots' x-axis scale in real time using tkinter? -



python - How to control individual matplotlib subplots' x-axis scale in real time using tkinter? -

first time posting stackoverflow i'll seek right...

i'm running info acquisition module in python who's input info stream output of different python module. tkinter sliders used control: scale of x-axis of plot (which plotting incoming data), , 'generation speed':

for axisnum in range( len( subplots ) ): wscale = tkinter.scale( master = roots[root], label = "view width on plot %s:" % ( axisnum ), from_ = 3, = 1000, orient = tkinter.horizontal, sliderlength = 30, length = subplots[axisnum].get_frame().get_window_extent().width, ) wscale2 = tkinter.scale( master = roots[root], label = "generation speed plot %s:" % ( axisnum ), from_ = 1, = 200, orient = tkinter.horizontal, sliderlength = 30, length = subplots[axisnum].get_frame().get_window_extent().width ) wscale2.pack( side = tkinter.bottom ) wscale.pack( side = tkinter.bottom ) wscale.set( 100 ) wscale2.set( wscale2['to'] - 3 )

the problem that, though creates 'n' pairs of slider widgets on canvas first active , acts 'master slider' controlling 'n' subplots simultaneously.

slight modifications have led 'x , y info must same length' beingness raised.

so suggestions on how can create tkinter sliders command scale of x-axis of individual subplots on single figure?

update

perhaps problem in realtimeplotter?

note dsets[figure][subs][data] info points specific subplot; subs should typically left @ '0'.

def realtimeplotter(): global dsets, wscaleslist, wscales2list in range(len(figures_list)): scale in wscaleslist: samples = min(len(dsets[i][0][0]),scale[0].get()) xaxis = pylab.arange(len(dsets[i][0][0])-samples, len(dsets[i][0][0], 1 ) t in range(len(linenum)-1): #we take lineax , axnum[1] because [0] figure number (lineax[t+1])[i].set_data(xaxis,pylab.array(dsets[i][0][t][-samples:]) (axinfo[t+1]).axis([xaxis.min(),xaxis.max(),-1.5,1.5]) canvas in range(len(canvaslist)): canvaslist[canvas].draw() root in range(len(roots)): roots[root].after(100,realtimeplotter)

there no problem illustration below there must in code not able duplicate. when "canvas" sliders on canvas object or figure of speech. also, type of object roots[root].

"only first active , acts 'master slider' controlling 'n' subplots simultaneously" think way possible if point same object.

import tkinter root=tkinter.tk() root.geometry("225x150") slide_length in (200, 150): wscale = tkinter.scale( master = root, label = "view width on plot ", from_ = 3, = 1000, orient = tkinter.horizontal, sliderlength = 30, length = slide_length) wscale.pack(side = tkinter.bottom) root.mainloop()

python matplotlib tkinter

No comments:

Post a Comment