Skip to content

Commit 608999b

Browse files
committed
Create sample image using matplotlib
This is a sample of what the images look like using matplotlib instead of Graph. + imgs/test_geometry/test_extrapolated_intersection/ aa01_test_point_line_no_intr.py - matplotlib to generate: + imgs/test_geometry/test_extrapolated_intersection/out/ aa01_test_point_line_no_intr_2.png - matplotlib generated file
1 parent 841ba3d commit 608999b

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import matplotlib.pyplot as plt
2+
import numpy as np
3+
4+
fig, ax = plt.subplots()
5+
renderer = fig.canvas.get_renderer()
6+
plt.xlim(-1, 7)
7+
plt.ylim(-1, 5)
8+
9+
ax.spines['left'].set_position('zero')
10+
ax.spines['right'].set_color('none')
11+
ax.spines['top'].set_color('none')
12+
ax.spines['bottom'].set_position('zero')
13+
ax.grid(True, linestyle='dashed')
14+
15+
ax.xaxis.get_major_ticks()[0].label1.set_visible(False)
16+
ax.xaxis.get_major_ticks()[1].label1.set_visible(False)
17+
ax.xaxis.get_major_ticks()[-1].label1.set_visible(False)
18+
ax.yaxis.get_major_ticks()[0].label1.set_visible(False)
19+
ax.yaxis.get_major_ticks()[1].label1.set_visible(False)
20+
ax.yaxis.get_major_ticks()[-1].label1.set_visible(False)
21+
ax.xaxis.get_majorticklines()[0].set_visible(False)
22+
ax.xaxis.get_majorticklines()[-2].set_visible(False)
23+
ax.yaxis.get_majorticklines()[0].set_visible(False)
24+
ax.yaxis.get_majorticklines()[-2].set_visible(False)
25+
ax.xaxis.get_gridlines()[0].set_visible(False)
26+
ax.xaxis.get_gridlines()[-1].set_visible(False)
27+
ax.yaxis.get_gridlines()[0].set_visible(False)
28+
ax.yaxis.get_gridlines()[-1].set_visible(False)
29+
30+
moving_pt = plt.scatter([1], [1], zorder=5)
31+
32+
moving_pt_an = plt.annotate(s="(1, 1)", xy=(1, 1), zorder=5)
33+
moving_pt_extents = moving_pt_an.get_window_extent(renderer)
34+
moving_pt_an.remove()
35+
moving_pt_an = ax.annotate(s="(1, 1)", xy=(1, 1), xytext=(-moving_pt_extents.width - 5, 5), textcoords='offset pixels', zorder=5)
36+
37+
moving_pt_ar = ax.annotate("", xy=(1, 1), xytext=(6, 1), arrowprops=dict(arrowstyle="<-", shrinkA=0, shrinkB=0, zorder=4))
38+
39+
segment_pts = ax.scatter([2, 6], [4, 2], c='r', zorder=5)
40+
segment_arrow = ax.annotate("", xy=(2, 4), xytext=(6, 2), arrowprops=dict(arrowstyle="-", shrinkA=0, shrinkB=0, color='b', zorder=4))
41+
42+
an24 = ax.annotate('(2, 4)', xy=(2, 4), xytext=(5, 5), textcoords='offset pixels')
43+
an62 = ax.annotate('(6, 2)', xy=(6, 2), xytext=(5, 5), textcoords='offset pixels')
44+
45+
plt.show()
17.3 KB
Loading

0 commit comments

Comments
 (0)