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

Skip to content

Commit 6256889

Browse files
Phil Elsonpelson
Phil Elson
authored and
pelson
committed
Tkinter logo added.
1 parent 561d0da commit 6256889

File tree

7 files changed

+1371
-0
lines changed

7 files changed

+1371
-0
lines changed

examples/api/mpl_icon.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""
2+
Thanks to Tony Yu <[email protected]> for the logo design
3+
"""
4+
5+
import numpy as np
6+
import matplotlib as mpl
7+
import matplotlib.pyplot as plt
8+
import matplotlib.cm as cm
9+
10+
mpl.rcParams['xtick.labelsize'] = 10
11+
mpl.rcParams['ytick.labelsize'] = 12
12+
mpl.rcParams['axes.edgecolor'] = 'gray'
13+
14+
15+
axalpha = 0.05
16+
figcolor = 'white'
17+
dpi = 124
18+
fig = plt.figure(figsize=(1, 1), dpi=dpi)
19+
#fig.figurePatch.set_edgecolor(figcolor)
20+
#fig.figurePatch.set_facecolor(figcolor)
21+
fig.figurePatch.set_alpha(0)
22+
23+
24+
def add_math_background():
25+
ax = fig.add_axes([0., 0., 1., 1.])
26+
27+
text = []
28+
#text.append((r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]$", (0.7, 0.2), 20))
29+
#text.append((r"$\frac{d\rho}{d t} + \rho \vec{v}\cdot\nabla\vec{v} = -\nabla p + \mu\nabla^2 \vec{v} + \rho \vec{g}$",
30+
# (0.35, 0.9), 20))
31+
text.append((r"$\int_{-\infty}^\infty e^{-x^2}dx=\sqrt{\pi}$",
32+
(-0.1, 0.75), 14))
33+
text.append((r"$E = mc^2 = \sqrt{{m_0}^2c^4 + p^2c^2}$",
34+
(0.05, 0.2), 12))
35+
text.append((r"$F_G = G\frac{m_1m_2}{r^2}$",
36+
(0.4, 0.46), 12))
37+
for eq, (x, y), size in text:
38+
ax.text(x, y, eq, ha='left', va='center', color="#11557c", alpha=0.25,
39+
transform=ax.transAxes, fontsize=size)
40+
ax.set_axis_off()
41+
return ax
42+
43+
def add_matplotlib_text(ax):
44+
ax.text(0.95, 0.5, 'matplotlib', color='#11557c', fontsize=65,
45+
ha='right', va='center', alpha=1.0, transform=ax.transAxes)
46+
47+
def add_polar_bar():
48+
ax = fig.add_axes([0.05, 0.05, 0.9, 0.9], polar=True, resolution=50)
49+
ax.axesPatch.set_facecolor('white')
50+
51+
# ax.axesPatch.set_alpha(axalpha)
52+
ax.set_axisbelow(True)
53+
N = 7
54+
arc = 2. * np.pi
55+
theta = np.arange(0.0, arc, arc/N)
56+
radii = 10 * np.array([0.2, 0.6, 0.8, 0.7, 0.4, 0.5, 0.8])
57+
width = np.pi / 4 * np.array([0.4, 0.4, 0.6, 0.8, 0.2, 0.5, 0.3])
58+
bars = ax.bar(theta, radii, width=width, bottom=0.0)
59+
for r, bar in zip(radii, bars):
60+
bar.set_facecolor(cm.jet(r/10.))
61+
bar.set_alpha(0.6)
62+
63+
for label in ax.get_xticklabels() + ax.get_yticklabels():
64+
label.set_visible(False)
65+
66+
for line in ax.get_ygridlines() + ax.get_xgridlines():
67+
line.set_lw(0.8)
68+
line.set_alpha(0.9)
69+
line.set_ls('-')
70+
line.set_color('0.5')
71+
72+
ax.set_yticks(np.arange(1, 9, 2))
73+
ax.set_rmax(9)
74+
75+
if __name__ == '__main__':
76+
#main_axes = add_math_background()
77+
add_polar_bar()
78+
#add_matplotlib_text(main_axes)
79+
plt.savefig('foo.png', dpi=dpi, )#transparent=True)
80+
#plt.show()
81+
82+

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ def new_figure_manager(num, *args, **kwargs):
7878
FigureClass = kwargs.pop('FigureClass', Figure)
7979
figure = FigureClass(*args, **kwargs)
8080
window = Tk.Tk()
81+
82+
# put a mpl icon on the window rather than the default tk icon. Tkinter
83+
# doesn't allow colour icons on linux systems, but tk >=8.5 has a iconphoto
84+
# command which we call directly. Source:
85+
# http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html
86+
icon_fname = os.path.join(rcParams['datapath'], 'images', 'logo.gif')
87+
icon_img = Tk.PhotoImage(file=icon_fname)
88+
window.tk.call('wm', 'iconphoto', window._w, icon_img)
89+
8190
canvas = FigureCanvasTkAgg(figure, master=window)
8291
figManager = FigureManagerTkAgg(canvas, num, window)
8392
if matplotlib.is_interactive():
5.63 KB
Loading
47 KB
Binary file not shown.
15.7 KB
Loading

lib/matplotlib/mpl-data/images/logo.ppm

Lines changed: 5 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)