Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c84d50c

Browse filesBrowse files
committed
made backend agg open png in binary mode
svn path=/branches/v0_91_maint/; revision=5171
1 parent 6354bfc commit c84d50c
Copy full SHA for c84d50c

File tree

Expand file treeCollapse file tree

6 files changed

+23
-32
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+23
-32
lines changed

‎examples/embedding_in_gtk2.py

Copy file name to clipboardExpand all lines: examples/embedding_in_gtk2.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66
import gtk
77

8-
from matplotlib.axes import Subplot
98
from matplotlib.figure import Figure
109
from numpy import arange, sin, pi
1110

‎examples/embedding_in_tk.py

Copy file name to clipboardExpand all lines: examples/embedding_in_tk.py
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#!/usr/bin/env python
2-
import matplotlib
3-
matplotlib.use('TkAgg')
4-
52
from numpy import arange, sin, pi
63
from matplotlib.axes import Subplot
74
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg

‎examples/embedding_in_tk2.py

Copy file name to clipboard
+19-24Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
11
#!/usr/bin/env python
2-
import matplotlib
3-
matplotlib.use('TkAgg')
4-
5-
from numpy import arange, sin, pi
6-
from matplotlib.axes import Subplot
7-
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
8-
from matplotlib.figure import Figure
9-
102
import Tkinter as Tk
11-
import sys
3+
import numpy as np
4+
import matplotlib.backends.backend_tkagg as backend
5+
import matplotlib.figure as mfigure
126

13-
def destroy(e): sys.exit()
147

158
root = Tk.Tk()
169
root.wm_title("Embedding in TK")
17-
#root.bind("<Destroy>", destroy)
1810

11+
fig = mfigure.Figure(figsize=(5,4), dpi=100)
12+
ax = fig.add_subplot(111)
13+
t = np.arange(0.0,3.0,0.01)
14+
s = np.sin(2*np.pi*t)
1915

20-
f = Figure(figsize=(5,4), dpi=100)
21-
a = f.add_subplot(111)
22-
t = arange(0.0,3.0,0.01)
23-
s = sin(2*pi*t)
24-
25-
a.plot(t,s)
26-
a.set_title('Tk embedding')
27-
a.set_xlabel('X axis label')
28-
a.set_ylabel('Y label')
16+
ax.plot(t,s)
17+
ax.grid(True)
18+
ax.set_title('Tk embedding')
19+
ax.set_xlabel('time (s)')
20+
ax.set_ylabel('volts (V)')
2921

3022

3123
# a tk.DrawingArea
32-
canvas = FigureCanvasTkAgg(f, master=root)
24+
canvas = backend.FigureCanvasTkAgg(fig, master=root)
3325
canvas.show()
3426
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
3527

36-
#toolbar = NavigationToolbar2TkAgg( canvas, root )
28+
#toolbar = backend.NavigationToolbar2TkAgg( canvas, root )
3729
#toolbar.update()
38-
canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
30+
#toolbar.pack(side=Tk.LEFT)
31+
32+
def destroy():
33+
raise SystemExit
3934

40-
button = Tk.Button(master=root, text='Quit', command=sys.exit)
35+
button = Tk.Button(master=root, text='Quit', command=destroy)
4136
button.pack(side=Tk.BOTTOM)
4237

4338
Tk.mainloop()

‎examples/mathtext_demo.py

Copy file name to clipboardExpand all lines: examples/mathtext_demo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
ax.set_ylabel(r'$\Delta_{i+1}^j$', fontsize=20)
1919
tex = r'$\mathcal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\sin(2 \pi f x_i)$'
2020

21-
ax.text(1, 1.6, tex, fontsize=20, va='bottom')
21+
mymath = ax.text(1, 1.6, tex, fontsize=20, va='bottom')
2222

2323
ax.legend(("Foo", "Testing $x^2$"))
2424

‎examples/mathtext_examples.py

Copy file name to clipboardExpand all lines: examples/mathtext_examples.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
r'$\widehat{abc}\widetilde{def}$',
5050
r'$\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega$',
5151
r'$\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon \phi \chi \psi$',
52-
ur'Generic symbol: $\u23ce \mathrm{\ue0f2 \U0001D538}$'
52+
#ur'Generic symbol: $\u23ce \mathrm{\ue0f2 \U0001D538}$'
5353
]
5454

5555
from pylab import *

‎lib/matplotlib/backends/backend_agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_agg.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,14 @@ def get_default_filetype(self):
390390
def print_raw(self, filename_or_obj, *args, **kwargs):
391391
self.draw()
392392
if type(filename_or_obj) in (str, unicode):
393-
filename_or_obj = open(filename_or_obj, 'w')
393+
filename_or_obj = file(filename_or_obj, 'wb')
394394
self.get_renderer()._renderer.write_rgba(filename_or_obj)
395395
print_rgba = print_raw
396396

397397
def print_png(self, filename_or_obj, *args, **kwargs):
398398
self.draw()
399399
if type(filename_or_obj) in (str, unicode):
400-
filename_or_obj = open(filename_or_obj, 'w')
400+
filename_or_obj = file(filename_or_obj, 'wb')
401401
self.get_renderer()._renderer.write_png(filename_or_obj,
402402
self.figure.dpi.get())
403403

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.