Created
June 25, 2019 13:21
-
-
Save hugoledoux/4f46b70246a876130093aba12b0ca2ba to your computer and use it in GitHub Desktop.
matplotlib polygons quickview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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