|
| 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 | + |
0 commit comments