-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_graph.py
More file actions
57 lines (40 loc) · 1.6 KB
/
Copy path_graph.py
File metadata and controls
57 lines (40 loc) · 1.6 KB
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
from matplotlib.ticker import MultipleLocator
import _sixel
def style_axes(ax, dim):
if dim == 3:
_style_axes_3d(ax)
else:
_style_axes_2d(ax)
def _style_axes_2d(ax):
# set the visible range of the x-axis
ax.set_xlim(-6, 6)
# set the visible range of the y-axis
ax.set_ylim(-6, 6)
# horizontal axis line; low zorder keeps it from painting over shape
# edges that happen to run along y=0
ax.axhline(0, color="gray", linewidth=1.5, zorder=0)
# vertical axis line; same zorder reasoning for edges along x=0
ax.axvline(0, color="gray", linewidth=1.5, zorder=0)
# space gridlines 0.5 units apart on both axes
ax.xaxis.set_major_locator(MultipleLocator(0.5))
ax.yaxis.set_major_locator(MultipleLocator(0.5))
# overlays gridlines at the axis tick marks
ax.grid(True)
def _style_axes_3d(ax):
# set the visible range on each axis
ax.set_xlim3d(-6, 6)
ax.set_ylim3d(-6, 6)
ax.set_zlim3d(-6, 6)
# reference lines through the origin along each axis, mirroring the 2D
# axhline/axvline treatment
ax.plot([-6, 6], [0, 0], [0, 0], color="gray", linewidth=1.5, zorder=0)
ax.plot([0, 0], [-6, 6], [0, 0], color="gray", linewidth=1.5, zorder=0)
ax.plot([0, 0], [0, 0], [-6, 6], color="gray", linewidth=1.5, zorder=0)
# space gridlines 0.5 units apart on each axis
ax.xaxis.set_major_locator(MultipleLocator(0.5))
ax.yaxis.set_major_locator(MultipleLocator(0.5))
ax.zaxis.set_major_locator(MultipleLocator(0.5))
# overlays gridlines at the axis tick marks
ax.grid(True)
def render():
_sixel.render()