Skip to content

Instantly share code, notes, and snippets.

@hugoledoux
Created June 25, 2019 13:21
Show Gist options
  • Save hugoledoux/4f46b70246a876130093aba12b0ca2ba to your computer and use it in GitHub Desktop.
Save hugoledoux/4f46b70246a876130093aba12b0ca2ba to your computer and use it in GitHub Desktop.
matplotlib polygons quickview
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.patches import Polygon
def main():
a = np.arange(8).reshape(4, 2)
a[0][0] = 0.0
a[0][1] = 0.0
a[1][0] = 2.0
a[1][1] = 0.0
a[2][0] = 3.0
a[2][1] = 4.0
a[3][0] = 2.0
a[3][1] = 11.0
show(a)
def show(re):
fig, ax = plt.subplots()
polygon = Polygon(re, ec="k")
ax.add_patch(polygon)
# fig.colorbar(p, ax=ax)
ax.margins(0.1)
ax.relim()
ax.autoscale_view()
plt.show()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment