Discussion:
[Matplotlib-users] MultiCursor messes with xlim and ylim autoscaling
Michael Kaufman
2016-01-20 18:26:13 UTC
Permalink
Hi Gurus:

I'm having a serious problem with MultiCursor and autoscaling...

If I do the code below with both MultiCursor instantiations commented
out, then all plots are xscaled to [50,55] and yscaled to each plot's
appropriate ylimits.

If I uncomment the top MultiCursor instantiation, then both the xlimits
and ylimits are screwed up: xlim=[0,60] and ylim is all over the place,
certainly not autoscaled tight.

If I uncomment the bottom MultiCursor instantiation, then the xlimit
appears to be scaled correctly, [50,55], but two of the four plots
(lower left and upper right) are not autoscaled in y.

How to I instantiate MultiCursor to get the normal and expected
autoscaling behavior?

Not that it should matter, but I'm using here Tk and Python3 with MPL
1.5dev1 (91ca2a3724ae91d28d97)

Thanks for any help,

M

=============

from matplotlib import pyplot as pl
from matplotlib.widgets import MultiCursor
from matplotlib import gridspec
import numpy as np

if __name__ == "__main__":

fig = pl.gcf()
gs = gridspec.GridSpec(2,2)

ax = None
for g in gs:
ax = pl.subplot(g, sharex=ax)

#multi = MultiCursor(fig.canvas, tuple(fig.axes),
# useblit=True, horizOn=True, color='k', lw=1)

x = np.arange(50,55,0.01)
y1 = np.sin(x)
y2 = np.cos(x) + 4
y3 = 0.2*np.cos(x) - 4
y4 = np.cos(2*x) - 1

for ax,y in zip(fig.axes, [y1,y2,y3,y4]):
ax.plot(x,y)

for ax in fig.axes:
ax.grid()

#multi = MultiCursor(fig.canvas, tuple(fig.axes),
# useblit=True, horizOn=True, color='k', lw=1)

pl.draw()
pl.show()
Bilheux, Jean-Christophe
2016-01-20 19:24:01 UTC
Permalink
HI all,

I wanted to help (for a change) but running the script on mac (with the multi cursor code commented out), I got the following error. If anyone can figure out why !

File "/Users/j35/anaconda/lib/python3.4/site-packages/matplotlib/widgets.py", line 1046, in clear
self.canvas.copy_from_bbox(self.canvas.figure.bbox))
AttributeError: 'FigureCanvasMac' object has no attribute ‘copy_from_bbox'

I’m using python 3.4 and matplotlib 1.4.3

Thanks

Jean
Post by Michael Kaufman
I'm having a serious problem with MultiCursor and autoscaling...
If I do the code below with both MultiCursor instantiations commented out, then all plots are xscaled to [50,55] and yscaled to each plot's appropriate ylimits.
If I uncomment the top MultiCursor instantiation, then both the xlimits and ylimits are screwed up: xlim=[0,60] and ylim is all over the place, certainly not autoscaled tight.
If I uncomment the bottom MultiCursor instantiation, then the xlimit appears to be scaled correctly, [50,55], but two of the four plots (lower left and upper right) are not autoscaled in y.
How to I instantiate MultiCursor to get the normal and expected autoscaling behavior?
Not that it should matter, but I'm using here Tk and Python3 with MPL 1.5dev1 (91ca2a3724ae91d28d97)
Thanks for any help,
M
=============
from matplotlib import pyplot as pl
from matplotlib.widgets import MultiCursor
from matplotlib import gridspec
import numpy as np
fig = pl.gcf()
gs = gridspec.GridSpec(2,2)
ax = None
ax = pl.subplot(g, sharex=ax)
#multi = MultiCursor(fig.canvas, tuple(fig.axes),
# useblit=True, horizOn=True, color='k', lw=1)
x = np.arange(50,55,0.01)
y1 = np.sin(x)
y2 = np.cos(x) + 4
y3 = 0.2*np.cos(x) - 4
y4 = np.cos(2*x) - 1
ax.plot(x,y)
ax.grid()
#multi = MultiCursor(fig.canvas, tuple(fig.axes),
# useblit=True, horizOn=True, color='k', lw=1)
pl.draw()
pl.show()
<multicursor_limtest.py>------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Benjamin Root
2016-01-20 20:00:06 UTC
Permalink
Add "blit=False" in the instantiation for multicursor to get around the
copy_from_bbox issue.

I wonder if the use of fig.axes might be a problem?
Post by Bilheux, Jean-Christophe
HI all,
I wanted to help (for a change) but running the script on mac (with the
multi cursor code commented out), I got the following error. If anyone can
figure out why !
File
"/Users/j35/anaconda/lib/python3.4/site-packages/matplotlib/widgets.py",
line 1046, in clear
self.canvas.copy_from_bbox(self.canvas.figure.bbox))
AttributeError: 'FigureCanvasMac' object has no attribute ‘copy_from_bbox'
I’m using python 3.4 and matplotlib 1.4.3
Thanks
Jean
Post by Michael Kaufman
I'm having a serious problem with MultiCursor and autoscaling...
If I do the code below with both MultiCursor instantiations commented
out, then all plots are xscaled to [50,55] and yscaled to each plot's
appropriate ylimits.
Post by Michael Kaufman
If I uncomment the top MultiCursor instantiation, then both the xlimits
and ylimits are screwed up: xlim=[0,60] and ylim is all over the place,
certainly not autoscaled tight.
Post by Michael Kaufman
If I uncomment the bottom MultiCursor instantiation, then the xlimit
appears to be scaled correctly, [50,55], but two of the four plots (lower
left and upper right) are not autoscaled in y.
Post by Michael Kaufman
How to I instantiate MultiCursor to get the normal and expected
autoscaling behavior?
Post by Michael Kaufman
Not that it should matter, but I'm using here Tk and Python3 with MPL
1.5dev1 (91ca2a3724ae91d28d97)
Post by Michael Kaufman
Thanks for any help,
M
=============
from matplotlib import pyplot as pl
from matplotlib.widgets import MultiCursor
from matplotlib import gridspec
import numpy as np
fig = pl.gcf()
gs = gridspec.GridSpec(2,2)
ax = None
ax = pl.subplot(g, sharex=ax)
#multi = MultiCursor(fig.canvas, tuple(fig.axes),
# useblit=True, horizOn=True, color='k', lw=1)
x = np.arange(50,55,0.01)
y1 = np.sin(x)
y2 = np.cos(x) + 4
y3 = 0.2*np.cos(x) - 4
y4 = np.cos(2*x) - 1
ax.plot(x,y)
ax.grid()
#multi = MultiCursor(fig.canvas, tuple(fig.axes),
# useblit=True, horizOn=True, color='k', lw=1)
pl.draw()
pl.show()
<multicursor_limtest.py>------------------------------------------------------------------------------
Post by Michael Kaufman
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
Post by Michael Kaufman
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Loading...