Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9b87fbc

Browse files
hmeineHans Meine
authored and
Hans Meine
committed
fix axes parameter editing when titles contain percent characters
I got an exception when pressing the "edit curves line and axes parameter" button on a plot with '%' in a subplot title: Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_qt4.py", line 456, in edit_parameters titles.append(text % repr(axes)) ValueError: unsupported format character ')' (0x29) at index 38 I had used sth. like: pylab.title("differences (in %)")
1 parent b516ae0 commit 9b87fbc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/matplotlib/backends/backend_qt4.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,15 +447,17 @@ def edit_parameters(self):
447447
title = axes.get_title()
448448
ylabel = axes.get_ylabel()
449449
if title:
450-
text = title
450+
fmt = "%(title)s"
451451
if ylabel:
452-
text += ": "+ylabel
453-
text += " (%s)"
452+
fmt += ": %(ylabel)s"
453+
fmt += " (%(axes_repr)s)"
454454
elif ylabel:
455-
text = "%%s (%s)" % ylabel
455+
fmt = "%(axes_repr)s (%(ylabel)s)" % ylabel
456456
else:
457-
text = "%s"
458-
titles.append(text % repr(axes))
457+
fmt = "%(axes_repr)s"
458+
titles.append(fmt % dict(title = title,
459+
ylabel = ylabel,
460+
axes_repr = repr(axes)))
459461
item, ok = QtGui.QInputDialog.getItem(self, 'Customize',
460462
'Select axes:', titles,
461463
0, False)

0 commit comments

Comments
 (0)