|
| 1 | +# ---------------------------------------------------------------------------- |
| 2 | +# Title: Scientific Visualisation - Python & Matplotlib |
| 3 | +# Author: Nicolas P. Rougier |
| 4 | +# License: BSD |
| 5 | +# ---------------------------------------------------------------------------- |
| 6 | +import numpy as np |
| 7 | +import matplotlib.pyplot as plt |
| 8 | +import matplotlib.ticker as ticker |
| 9 | + |
| 10 | +# Setup a plot such that only the bottom spine is shown |
| 11 | +def setup(ax): |
| 12 | + ax.spines['right'].set_color('none') |
| 13 | + ax.spines['left'].set_color('none') |
| 14 | + ax.yaxis.set_major_locator(ticker.NullLocator()) |
| 15 | + ax.spines['top'].set_color('none') |
| 16 | + |
| 17 | + ax.spines['bottom'].set_position("center") |
| 18 | + |
| 19 | + ax.xaxis.set_ticks_position('bottom') |
| 20 | + ax.tick_params(which='major', width=1.00) |
| 21 | + ax.tick_params(which='major', length=5) |
| 22 | + ax.tick_params(which='minor', width=0.75) |
| 23 | + ax.tick_params(which='minor', length=2.5) |
| 24 | + ax.set_xlim(0, 5) |
| 25 | + ax.set_ylim(0, 1) |
| 26 | + ax.patch.set_alpha(0.0) |
| 27 | + |
| 28 | + |
| 29 | +fig = plt.figure(figsize=(5, .5)) |
| 30 | +fig.patch.set_alpha(0.0) |
| 31 | +n = 1 |
| 32 | + |
| 33 | +fontsize = 18 |
| 34 | +ax = plt.subplot(n, 1, 1) |
| 35 | +ax.tick_params(axis='both', which='minor', labelsize=6) |
| 36 | +setup(ax) |
| 37 | +ax.xaxis.set_major_locator(ticker.MultipleLocator(1.0)) |
| 38 | +ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.2)) |
| 39 | +ax.xaxis.set_major_formatter(ticker.ScalarFormatter()) |
| 40 | +ax.xaxis.set_minor_formatter(ticker.ScalarFormatter()) |
| 41 | +ax.tick_params(axis='x', which='minor', rotation=0) |
| 42 | + |
| 43 | +for tick in ax.get_xticklabels(): |
| 44 | + tick.set_fontname("Roboto Condensed") |
| 45 | + |
| 46 | +plt.tight_layout() |
| 47 | +plt.savefig("../figures/tip-font-family.pdf", transparent=True) |
| 48 | +# plt.show() |
0 commit comments