-
-
Notifications
You must be signed in to change notification settings - Fork 970
/
standard-layout-2.py
63 lines (56 loc) · 1.86 KB
/
standard-layout-2.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
# ----------------------------------------------------------------------------
# Title: Scientific Visualisation - Python & Matplotlib
# Author: Nicolas P. Rougier
# License: BSD
# ----------------------------------------------------------------------------
#
# ----------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
p = plt.rcParams
p["figure.figsize"] = 6, 6
p["font.sans-serif"] = ["Roboto Condensed"]
p["font.weight"] = "light"
p["ytick.minor.visible"] = True
p["xtick.minor.visible"] = True
X = np.random.normal(0.5, 0.15, 5000)
Y = np.random.normal(0.5, 0.15, 5000)
fig = plt.figure(constrained_layout=True)
nrows, ncols, ratio = 2, 2, 5
gspec = gridspec.GridSpec(
ncols=ncols,
nrows=nrows,
figure=fig,
height_ratios=[1, ratio],
width_ratios=[ratio, 1],
)
ax = plt.subplot(gspec[1, 0])
ax.scatter(X, Y, s=15, facecolor="black", linewidth=0, alpha=0.25)
ax.set_xlim(0, 1), ax.set_xticks(np.linspace(0, 1, 5))
ax.set_ylim(0, 1), ax.set_yticks(np.linspace(0, 1, 5))
ax = plt.subplot(gspec[0, 0])
ax.set_xlim(0, 1), ax.set_xticks(np.linspace(0, 1, 5))
ax.set_xticklabels([]), ax.set_yticks([])
ax.spines["right"].set_visible(False)
ax.spines["left"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.hist(
X, bins=np.linspace(0, 1, 21), facecolor="0.75", edgecolor="white", linewidth=0.5
)
ax = plt.subplot(gspec[1, 1])
ax.set_ylim(0, 1), ax.set_yticks(np.linspace(0, 1, 5))
ax.set_yticklabels([]), ax.set_xticks([])
ax.spines["right"].set_visible(False)
ax.spines["bottom"].set_visible(False)
ax.spines["top"].set_visible(False)
H = ax.hist(
Y,
bins=np.linspace(0, 1, 21),
facecolor="0.75",
edgecolor="white",
orientation="horizontal",
linewidth=0.5,
)
plt.savefig("../../figures/layout/standard-layout-2.pdf")
plt.show()