|
| 1 | +""" |
| 2 | +Thanks to Tony Yu <[email protected]> for the logo design |
| 3 | +""" |
| 4 | + |
1 | 5 | import numpy as np |
| 6 | +import matplotlib as mpl |
2 | 7 | import matplotlib.pyplot as plt |
3 | 8 | import matplotlib.cm as cm |
4 | 9 | import matplotlib.mlab as mlab |
| 10 | +from pylab import rand |
5 | 11 |
|
6 | | -axalpha = 0.05 |
7 | | -figcolor = '#FFFFCC' |
8 | | -dpi = 80 |
9 | | -fig = plt.figure(figsize=(8, 2),dpi=dpi) |
10 | | -fig.patch.set_edgecolor(figcolor) |
11 | | -fig.patch.set_facecolor(figcolor) |
12 | | - |
13 | | -# the polar bar plot |
14 | | -ax = fig.add_axes([0.05, 0.05, 0.2, 01], polar=True) |
15 | | -ax.patch.set_alpha(axalpha) |
16 | | -N = 20 |
17 | | -theta = np.arange(0.0, 2*np.pi, 2*np.pi/N) + np.pi |
18 | | -radii = 10*np.random.rand(N) |
19 | | -width = np.pi/6*np.random.rand(N) |
20 | | -#radii = np.log(np.arange(1,N+1)) |
21 | | -#width = np.arange(N, dtype=float)/N*np.pi/8 |
22 | | - |
23 | | -bars = ax.bar(theta, radii, width=width, bottom=0.0) |
24 | | -for r,bar in zip(radii, bars): |
25 | | - bar.set_facecolor( cm.jet(r/10.)) |
26 | | - bar.set_alpha(0.5) |
27 | | - |
28 | | -for label in ax.get_xticklabels() + ax.get_yticklabels(): |
29 | | - label.set_visible(False) |
30 | | - |
31 | | - |
32 | | -# the histogram |
33 | | -axhist = fig.add_axes([0.275, 0.075, 0.2, 0.4]) |
34 | | -axhist.patch.set_alpha(axalpha) |
35 | | -mu, sigma = 100, 15 |
36 | | -x = mu + sigma*np.random.randn(10000) |
37 | | - |
38 | | -# the histogram of the data |
39 | | -n, bins, patches = axhist.hist(x, 20, normed=1, |
40 | | - facecolor='green', edgecolor='green', alpha=0.75) |
| 12 | +mpl.rcParams['xtick.labelsize'] = 6 |
| 13 | +mpl.rcParams['ytick.labelsize'] = 6 |
| 14 | +mpl.rcParams['axes.edgecolor'] = 'gray' |
41 | 15 |
|
42 | 16 |
|
43 | | -y = mlab.normpdf( bins, mu, sigma) |
44 | | -l = axhist.plot(bins, y, 'r', lw=1) |
45 | | - |
46 | | -axhist.set_title('Density of IQ',fontsize=6) |
47 | | -axhist.set_xlabel('IQ', fontsize=6) |
48 | | -axhist.set_ylabel('P(IQ)', fontsize=6) |
49 | | -ax.set_xlim(-2*sigma, 2*sigma) |
50 | | -for label in axhist.get_xticklabels() + axhist.get_yticklabels(): |
51 | | - label.set_visible(False) |
52 | | - |
53 | | - |
54 | | -axback = fig.add_axes([0., 0., 1., 1.]) |
55 | | - |
56 | | -#the math background |
57 | | -tex = 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]$" |
58 | | -radargreen = '#d5de9c' |
59 | | -orange = '#ee8d18' |
60 | | -axback.text(0.5, 0.5, tex, |
61 | | - transform=axback.transAxes, color='black', alpha=0.25, fontsize=40, |
62 | | - ha='center', va='center') |
63 | | -axback.set_axis_off() |
64 | | - |
65 | | -# the matplotlib title |
66 | | -axback.text(0.3, 0.95, 'matplotlib', color='black', fontsize=75, |
67 | | - ha='left', va='top', alpha=1.0, |
68 | | - transform=axback.transAxes) |
69 | | - |
| 17 | +axalpha = 0.05 |
| 18 | +#figcolor = '#EFEFEF' |
| 19 | +figcolor = 'white' |
| 20 | +dpi = 80 |
| 21 | +fig = plt.figure(figsize=(6, 1.),dpi=dpi) |
| 22 | +fig.figurePatch.set_edgecolor(figcolor) |
| 23 | +fig.figurePatch.set_facecolor(figcolor) |
| 24 | + |
| 25 | + |
| 26 | +def add_math_background(): |
| 27 | + ax = fig.add_axes([0., 0., 1., 1.]) |
| 28 | + |
| 29 | + text = [] |
| 30 | + 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)) |
| 31 | + 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}$", |
| 32 | + (0.35, 0.9), 20)) |
| 33 | + text.append((r"$\int_{-\infty}^\infty e^{-x^2}dx=\sqrt{\pi}$", |
| 34 | + (0.15, 0.3), 25)) |
| 35 | + #text.append((r"$E = mc^2 = \sqrt{{m_0}^2c^4 + p^2c^2}$", |
| 36 | + # (0.7, 0.42), 30)) |
| 37 | + text.append((r"$F_G = G\frac{m_1m_2}{r^2}$", |
| 38 | + (0.85, 0.7), 30)) |
| 39 | + for eq, (x, y), size in text: |
| 40 | + ax.text(x, y, eq, ha='center', va='center', color="#11557c", alpha=0.25, |
| 41 | + transform=ax.transAxes, fontsize=size) |
| 42 | + ax.set_axis_off() |
| 43 | + return ax |
| 44 | + |
| 45 | +def add_matplotlib_text(ax): |
| 46 | + ax.text(0.975, 0.5, 'matplotlib', color='#11557c', fontsize=65, |
| 47 | + ha='right', va='center', alpha=1.0, transform=ax.transAxes) |
| 48 | + |
| 49 | +def add_polar_bar(): |
| 50 | + ax = fig.add_axes([0.05, 0.1, 0.2, 0.8], polar=True) |
| 51 | + ax.axesPatch.set_alpha(axalpha) |
| 52 | + N = 7 |
| 53 | + arc = 2. * np.pi |
| 54 | + theta = np.arange(0.0, arc, arc/N) |
| 55 | + radii = 10 * np.array([0.2, 0.6, 1.0, 0.7, 0.4, 0.5, 0.8]) |
| 56 | + width = np.pi / 4 * np.array([0.4, 0.4, 0.6, 0.8, 0.2, 0.5, 0.3]) |
| 57 | + bars = ax.bar(theta, radii, width=width, bottom=0.0) |
| 58 | + for r, bar in zip(radii, bars): |
| 59 | + bar.set_facecolor(cm.jet(r/10.)) |
| 60 | + bar.set_alpha(0.6) |
| 61 | + |
| 62 | +if __name__ == '__main__': |
| 63 | + main_axes = add_math_background() |
| 64 | + add_polar_bar() |
| 65 | +# add_histogram() |
| 66 | +# add_scatter() |
| 67 | +# add_pcolor() |
| 68 | + #add_pcolor2() |
| 69 | + add_matplotlib_text(main_axes) |
| 70 | + fig.savefig('logo2.png', facecolor=figcolor, edgecolor=figcolor, dpi=dpi) |
| 71 | + plt.show() |
70 | 72 |
|
71 | | -fig.savefig('logo2.png', facecolor=figcolor, edgecolor=figcolor, dpi=dpi) |
72 | | -plt.show() |
73 | 73 |
|
0 commit comments