-
-
Notifications
You must be signed in to change notification settings - Fork 991
/
transforms-polar.py
32 lines (28 loc) · 1 KB
/
transforms-polar.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
# ----------------------------------------------------------------------------
# Title: Scientific Visualisation - Python & Matplotlib
# Author: Nicolas P. Rougier
# License: Creative Commons BY-NC-SA International 4.0
# ----------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.transforms as transforms
fig = plt.figure(figsize=(5, 5), dpi=100)
ax = fig.add_subplot(1, 1, 1, projection="polar")
ax.set_ylim(-1, 1), ax.set_yticks([-1, -0.5, 0, 0.5, 1])
FC_to_DC = ax.transData.inverted().transform
NDC_to_FC = ax.transAxes.transform
NDC_to_DC = lambda x: FC_to_DC(NDC_to_FC(x))
P = NDC_to_DC([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]])
plt.plot(
P[:, 0],
P[:, 1],
clip_on=False,
color="k",
linewidth=1.0,
linestyle="--",
zorder=-10,
)
plt.scatter(P[:-1, 0], P[:-1, 1], clip_on=False, facecolor="w", edgecolor="k")
plt.tight_layout()
plt.savefig("../../figures/coordinates/transforms-polar.pdf")
plt.show()