Skip to content

Commit

Permalink
fixed canvas switcher bug
Browse files Browse the repository at this point in the history
svn path=/trunk/matplotlib/; revision=943
  • Loading branch information
jdh2358 committed Feb 8, 2005
1 parent 4376f1c commit 81188fb
Show file tree
Hide file tree
Showing 16 changed files with 227 additions and 87 deletions.
3 changes: 2 additions & 1 deletion API_CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ API CHANGES in matplotlib-0.72

subs=none now does autosubbing in the tick locator.

removed BBoxTransformation
New subplots that overlap old will delete the old axes. If you do
not want this behavior, use fig.add_subplot or the axes command

API CHANGES in matplotlib-0.71

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include API_CHANGES CHANGELOG KNOWN_BUGS INSTALL
include API_CHANGES CHANGELOG KNOWN_BUGS INSTALL NUMARRAY_ISSUES
include INTERACTIVE TODO
include Makefile MANIFEST.in MANIFEST
include .matplotlibrc
Expand Down
46 changes: 1 addition & 45 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -642,48 +642,4 @@ ZeroDivisionError: SeparableTransformation::eval_scalars yin interval is zero; c

-- fix contour mappable to work under changes in clim, cmap

-- port colorbar, current mappable to API

-- add qt / gpl warning

-- Nil's xtick labeling bug

-- make a fig dict wrapper

-- plot items ala gnuplot
FileItem, FuncItem, High level plot items

-- doc why figimage doesn't respond to nav

- imshow() bug: make a random 1024x1024 array, zoom in hard (to a 10x10
square). All displayed area is white.


-- Tk figure destruction bugs with mayavi. Already reported.

-- run in ipython with -backend


- easy interactive logscaling x/y axes independently. (l->y, L->x) Button?

- grid on/off toggle (g key), button?

- measuring ruler? (see gnuplot's 'r' hotkey in X11).

- button to add text labels easily anywhere on the plot. A few drawing
buttons as well for simple things? Circle/ellipse, box, arrows, etc.

- toggle log/linear shows strange accumulation of ticks on y axis

from pylab import *
x = arange(-2.00, 10, 0.01)
y = exp(-x)
plot(x,y)
#set(gca(), xscale='log')
show()

-- DONE pyparsing a performance bottleneck for log ticks

-- DONE draw point and draw pixel currently broken for new style markers

-- alpha channel in colormaps
-- make subplot delaxes on other subplots under it.
10 changes: 9 additions & 1 deletion lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,19 @@ def destroy(self):
pass

def key_press(self, event):

# these bindings happen whether you are over an axes or not
#if event.key == 'q':
# self.destroy() # how cruel to have to destroy oneself!
# return

if event.inaxes is None: return

# the mouse has to be over an axes to trigger these
if event.key == 'g':
event.inaxes.grid()
self.canvas.draw()
if event.key == 'l':
elif event.key == 'l':
event.inaxes.toggle_log_lineary()
self.canvas.draw()

Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,4 @@ def print_figure(self, filename, dpi=150,
self.figure.dpi.set(origDPI)
self.figure.set_facecolor(origfacecolor)
self.figure.set_edgecolor(origedgecolor)
self.figure.set_canvas(self)
3 changes: 2 additions & 1 deletion lib/matplotlib/backends/backend_fltkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ def print_figure(self, filename, dpi=150,

agg = self.switch_backends(FigureCanvasAgg)
agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)

self.figure.set_canvas(self)

def widget(self):
return self.canvas

Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/backends/backend_gdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,5 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
error_msg('Format "%s" is not supported.\nSupported formats are %s.' %
(ext, ', '.join(IMAGE_FORMAT)),
parent=self)

self.figure.set_canvas(self)
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
self.figure.set_facecolor(origfacecolor)
self.figure.set_edgecolor(origedgecolor)
self.figure.set_figsize_inches(origWIn, origHIn)

self.figure.set_canvas(self)

class FigureManagerGTK(FigureManagerBase):
"""
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_gtkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def print_figure(self, filename, dpi=150,
agg = self.switch_backends(FigureCanvasAgg)
agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)

self.figure.set_canvas(self)


def configure_event(self, widget, event=None):
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ def draw_line(self, gc, x0, y0, x1, y1):

def _draw_markers(self, gc, path, x, y, transform):
"""
I'm underscore hiding this method from lines.py right now
since it is incomplete
Draw the markers defined by path at each of the positions in x
and y. path coordinates are points, x and y coords will be
transformed by the transform
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_qtagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def print_figure(self, filename, dpi=150,

agg = self.switch_backends(FigureCanvasAgg)
agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)
self.figure.set_canvas(self)

class NavigationToolbar2QtAgg(NavigationToolbar2, qt.QToolBar):
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_tkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def print_figure(self, filename, dpi=150,

agg = self.switch_backends(FigureCanvasAgg)
agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)

self.figure.set_canvas(self)

def motion_notify_event(self, event):
x = event.x
Expand Down
4 changes: 3 additions & 1 deletion lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ def print_figure(self, filename, dpi=150,

ps.print_figure(filename, 72, facecolor, edgecolor)
self.figure.dpi.set(origDPI)
self.figure.set_canvas(self)
return
elif ext.find('svg')>=0:
# enable svg save from WX backend only import this if we
Expand All @@ -907,7 +908,8 @@ def print_figure(self, filename, dpi=150,
svg = self.switch_backends(FigureCanvasSVG)
svg.figure.dpi.set(72)
svg.print_figure(filename, 72, facecolor, edgecolor)
self.figure.dpi.set(origDPI)
self.figure.dpi.set(origDPI)
self.figure.set_canvas(self)
return

if not self._isRealized:
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_wxagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def print_figure(self, filename, dpi=150, facecolor='w',
"""
agg = self.switch_backends(FigureCanvasAgg)
agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)
self.figure.set_canvas(self)

def _get_imagesave_wildcards(self):
'return the wildcard string for the filesave dialog'
Expand Down
23 changes: 21 additions & 2 deletions lib/matplotlib/pylab.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,8 @@ def figlegend(handles, labels, loc, **kwargs):
return l

def savefig(*args, **kwargs):
try: ret = gcf().savefig(*args, **kwargs)
fig = gcf()
try: ret = fig.savefig(*args, **kwargs)
except RuntimeError, msg:
msg = raise_msg_to_str(msg)
error_msg(msg)
Expand Down Expand Up @@ -1266,10 +1267,28 @@ def subplot(*args, **kwargs):
See help(axes) for additional information on axes and subplot
keyword arguments.
New subplots that overlap old will delete the old axes. If you do
not want this behavior, use fig.add_subplot or the axes command. Eg
from pylab import *
plot([1,2,3]) # implicitly creates subplot(111)
subplot(211) # overlaps, subplot(111) is killed
plot(rand(12), rand(12))
"""

try:
a = gcf().add_subplot(*args, **kwargs)
fig = gcf()
a = fig.add_subplot(*args, **kwargs)
bbox = a.bbox
byebye = []
for other in fig.axes:
if other==a: continue
if bbox.overlaps(other.bbox):
byebye.append(other)
for ax in byebye: delaxes(ax)

except ValueError, msg:
msg = raise_msg_to_str(msg)
error_msg(msg)
Expand Down
Loading

0 comments on commit 81188fb

Please sign in to comment.