-
Notifications
You must be signed in to change notification settings - Fork 906
/
Copy pathscales.py
64 lines (55 loc) · 2.57 KB
/
scales.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import pathlib
import numpy as np
import matplotlib.pyplot as plt
ROOT_DIR = pathlib.Path(__file__).parent.parent
fig = plt.figure(figsize=(0.4, 2/3*0.4))
ax = fig.add_axes([0, 0, 1, 1], frameon=False)
ax.tick_params(axis='both', which='both', length=0)
ax.set_xlim(-2, 2)
X = np.linspace(-2, +2, 1001)
Y = np.sin(X*2.5*2*np.pi)
# Linear scale
# -----------------------------------------------------------------------------
ax.set_xlim(X.min(), X.max())
ax.set_xscale("linear")
ax.plot(X, Y, color="C1", linewidth=0.75)
ax.set_ylim(-2.5, 1.5)
ax.text(0, 0.12, "-∞", ha="left", va="bottom", size=3, transform=ax.transAxes)
ax.text(0, 0.15, "⇤", ha="left", va="top", size=4, transform=ax.transAxes)
ax.text(1, 0.12, "+∞", ha="right", va="bottom", size=3, transform=ax.transAxes)
ax.text(1, 0.15, "⇥", ha="right", va="top", size=4, transform=ax.transAxes)
fig.savefig(ROOT_DIR / "figures/scale-linear.pdf")
ax.clear()
# Log scale
# -----------------------------------------------------------------------------
ax.set_xscale("log", base=10)
ax.plot(X, Y, color="C1", linewidth=0.75)
ax.set_ylim(-2.5, 1.5)
ax.text(0, 0.12, "0", ha="left", va="bottom", size=3, transform=ax.transAxes)
ax.text(0, 0.15, "⇤", ha="left", va="top", size=4, transform=ax.transAxes)
ax.text(1, 0.12, "+∞", ha="right", va="bottom", size=3, transform=ax.transAxes)
ax.text(1, 0.15, "⇥", ha="right", va="top", size=4, transform=ax.transAxes)
fig.savefig(ROOT_DIR / "figures/scale-log.pdf")
ax.clear()
# Symlog scale
# -----------------------------------------------------------------------------
ax.set_xscale("symlog", base=10, linthresh=1)
ax.plot(X, Y, color="C1", linewidth=0.75)
ax.set_ylim(-2.5, 1.5)
ax.text(0, 0.12, "-∞", ha="left", va="bottom", size=3, transform=ax.transAxes)
ax.text(0, 0.15, "⇤", ha="left", va="top", size=4, transform=ax.transAxes)
ax.text(1, 0.12, "+∞", ha="right", va="bottom", size=3, transform=ax.transAxes)
ax.text(1, 0.15, "⇥", ha="right", va="top", size=4, transform=ax.transAxes)
fig.savefig(ROOT_DIR / "figures/scale-symlog.pdf")
ax.clear()
# Symlog scale
# -----------------------------------------------------------------------------
ax.set_xscale("logit")
ax.plot(X, Y, color="C1", linewidth=0.75)
ax.set_ylim(-2.5, 1.5)
ax.text(0, 0.12, "0", ha="left", va="bottom", size=3, transform=ax.transAxes)
ax.text(0, 0.15, "⇤", ha="left", va="top", size=4, transform=ax.transAxes)
ax.text(1, 0.12, "1", ha="right", va="bottom", size=3, transform=ax.transAxes)
ax.text(1, 0.15, "⇥", ha="right", va="top", size=4, transform=ax.transAxes)
fig.savefig(ROOT_DIR / "figures/scale-logit.pdf")
ax.clear()