Hello,
I seem to have uncovered a bug in setting/updating the axis limits.
If you run the following example, you should see a straight line between
(0,0) and (1,1). Pressing the "Test Zoom" button should reset the axis
limits to the values depicted below. Basically, the X axis is clipped
between [0.1,0.8] and the Y axis limits are either [0.516,0.517] or
[0.5166,0.5167] depending on which of the two lines in the code below is
commented. The following bug(s) are seen:
1. In the first case, where the y axis limit is updated to
[0.516,0.517], the line should be seen as a sharply vertical line
passing starting from x=0.516 and continuing sharply upwards till
x=0.517. However, the line seems to start significantly _after_
x=0.52.
2. In the second case, if the ylim variable is changed to
[0.5166,0.5167], then the line completely dissapears from the axes
view. It seems to fall off the right edge (is my guess), whereas it
should be seen as a more or less vertical line passing through
x=0.5166.
The test code is appended below the signature.
Thanks,
Srinath
import matplotlib
matplotlib.use('GTK')
from matplotlib.backends.backend_gtk import FigureCanvasGTK
from matplotlib.axes import Subplot
from matplotlib.figure import Figure
import gtk
class MyApp:
def __init__(self):
self.win = gtk.Window()
self.win.set_name("Embedding in GTK")
self.win.connect("destroy", gtk.mainquit)
self.win.set_border_width(5)
self.vbox = gtk.VBox(spacing=3)
self.win.add(self.vbox)
self.vbox.show()
self.fig = Figure(figsize=(5,4), dpi=100)
self.ax = Subplot(self.fig, 111)
self.ax.plot([0,1], [0,1])
self.fig.add_axis(self.ax)
self.canvas = FigureCanvasGTK(self.fig) # a gtk.DrawingArea
self.canvas.show()
self.vbox.pack_start(self.canvas)
buttonTestZoom = gtk.Button('Test Zoom')
buttonTestZoom.connect('button_press_event', self.TestZoom)
buttonTestZoom.show()
self.vbox.pack_start(buttonTestZoom)
self.win.show()
def TestZoom(self, widget, event):
self.ax.update_viewlim()
xlim = [0.1, 0.8]
# this makes the line dissapear from the axes.
#ylim = [0.5166, 0.5167]
# this shows the line but in the wrong location!
ylim = [0.516, 0.517]
self.ax.set_xlim(xlim)
self.ax.set_ylim(ylim)
self.canvas.draw()
if __name__=='__main__':
app = MyApp()
gtk.mainloop()