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 1ca97fd

Browse filesBrowse files
committed
Add example code for current logo
1 parent 44fe937 commit 1ca97fd
Copy full SHA for 1ca97fd

File tree

Expand file treeCollapse file tree

1 file changed

+98
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+98
-0
lines changed

‎examples/misc/logos2.py

Copy file name to clipboardExpand all lines: examples/misc/logos2.py
+98Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,104 @@
88
Thanks to Tony Yu <tsyu80@gmail.com> for the logo design
99
"""
1010

11+
import numpy as np
12+
import matplotlib as mpl
13+
import matplotlib.pyplot as plt
14+
import matplotlib.cm as cm
15+
from matplotlib.patches import Circle, Rectangle
16+
17+
18+
def make_logo(pixels, lw_bars, lw_grid, lw_border, rgrid):
19+
mpl_blue = '#11557c'
20+
dpi = 100
21+
22+
with plt.rc_context({'axes.edgecolor': mpl_blue,
23+
'axes.linewidth': lw_border}):
24+
fig = plt.figure(figsize=(pixels / dpi, pixels / dpi), dpi=dpi)
25+
fig.patch.set_alpha(0)
26+
27+
ax = fig.add_axes((0.03, 0.03, .94, .94), projection='polar')
28+
ax.set_axisbelow(True)
29+
30+
N = 7
31+
arc = 2. * np.pi
32+
theta = np.arange(0.0, arc, arc / N)
33+
radii = np.array([2, 6, 8, 7, 4, 5, 8])
34+
width = np.pi / 4 * np.array([0.4, 0.4, 0.6, 0.8, 0.2, 0.5, 0.3])
35+
bars = ax.bar(theta, radii, width=width, bottom=0.0, align='edge',
36+
edgecolor='0.1', lw=lw_bars, )
37+
for r, bar in zip(radii, bars):
38+
color = *cm.jet(r / 10.)[:3], 0.6 # color from jet with alpha=0.6
39+
bar.set_facecolor(color)
40+
41+
ax.tick_params(labelbottom=False, labeltop=False,
42+
labelleft=False, labelright=False)
43+
44+
ax.grid(lw=lw_grid, ls=':', color='0.7')
45+
ax.set_rmax(9)
46+
ax.set_yticks(rgrid)
47+
48+
# the actual visible background - extends a bit beyond the axis
49+
ax.add_patch(Rectangle((0, 0), arc, 9.58,
50+
facecolor='white', zorder=0,
51+
clip_on=False, in_layout=False))
52+
return fig, ax
53+
54+
55+
params_large = {
56+
'pixels': 300,
57+
'lw_bars': 2,
58+
'lw_grid': 0.8,
59+
'lw_border': 3,
60+
'rgrid': [1, 3, 5, 7],
61+
}
62+
fig, ax = make_logo(**params_large)
63+
plt.savefig('logo_large.png')
64+
65+
##############################################################################
66+
67+
params_medium = {
68+
'pixels': 64,
69+
'lw_bars': 0.5,
70+
'lw_grid': 0.5,
71+
'lw_border': 1,
72+
'rgrid': [3, 6],
73+
}
74+
75+
make_logo(**params_medium)
76+
plt.savefig('logo_medium.png')
77+
78+
##############################################################################
79+
80+
params_small = {
81+
'pixels': 32,
82+
'lw_bars': 0.3,
83+
'lw_grid': 0.3,
84+
'lw_border': 0.3,
85+
'rgrid': [5],
86+
}
87+
88+
make_logo(**params_small)
89+
plt.savefig('logo_small.png')
90+
91+
##############################################################################
92+
93+
params_xsmall = {
94+
'pixels': 16,
95+
'lw_bars': 0.1,
96+
'lw_grid': 0.3,
97+
'lw_border': 0.3,
98+
'rgrid': [],
99+
}
100+
101+
make_logo(**params_xsmall)
102+
plt.savefig('logo_xsmall.png')
103+
104+
##############################################################################
105+
#
106+
# Old stuff
107+
# """""""""
108+
11109
import numpy as np
12110
import matplotlib as mpl
13111
import matplotlib.pyplot as plt

0 commit comments

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