I'm using the class API with TkAgg (and matplotlib 0.87.7) to plot
cumulative data with a known X range and an unknown Y range. The basic
code is appended. In summary: it all happens on one Axis on one Figure
and most of it happens with one Line. I'm running into a few problems:
- If I use frameon=False when creating my Figure then when I set the
plot X scale the old scale is also shown, resulting in a messy display.
Two sets of tick labels (old and new) overlap. Simply using frameon=True
prevents this. Is this a bug or a feature?
- I initially tried frameon=False because the plot frame contains a
1/16" white border that cuts off the edges of the text of the axis
labels. Is there an easy way to get rid of that white border?
- I plot data points as they slowly arrive. To do this I get a Line:
plotLine = self.plotAxis.plot([], [], 'bo')[0]
and then as data comes in, I use set_data to update it:
plotLine.set_data(focPosArr[:measInd], fwhmArr[:measInd])
This works except that autoscale does *not* occur so I have to manually
set the Y scale each time.
I am guessing autoscaling is only performed as part of a plot command,
not as a result of set_data, and perhaps this is a feature (potentially
useful if lots of data comes in quickly). If so, is there a workaround
that is preferable to manually setting the Y scale each time?
-- Russell
P.S. I set things up this way:
plotFig = Figure(figsize=(4,1), frameon=True)
self.figCanvas = FigureCanvasTkAgg(plotFig, sr.master)
col = gr.getNextCol()
row = gr.getNextRow()
self.figCanvas.get_tk_widget().grid(row=0, column=col,
rowspan=row, sticky="news")
self.plotAxis = plotFig.add_subplot(1, 1, 1)
Then for every "run" of this code I initialize the plot this way:
self.plotAxis.clear()
self.plotAxis.set_xlabel("Focus Offset (microns)")
self.plotAxis.set_ylabel("FWHM (pixels)")
self.plotAxis.grid(True)
#self.plotAxis.set_autoscale_on(True)
self.plotAxis.autoscale_view(scalex=False, scaley=True)
plotLine = self.plotAxis.plot([], [], 'bo')[0]
self.plotAxis.set_xlim((minFoc, maxFoc))
self.figCanvas.draw()
(In not sure if both autoscale commands are needed; the manual is pretty
vague on this point).