- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I plot Shapely polygons and objects using Matplotlib?
To plot shapely polygons and objects using matplotlib, the steps are as follows −
Create a polygon object using (x, y) data points.
Get x and y, the exterior data, and the array using polygon.exterior.xy.
Plot x and y data points using plot() method with red color.
Example
from shapely.geometry import Polygon import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True polygon1 = Polygon([(0, 5), (1, 1), (3, 0), (4, 6), ]) x, y = polygon1.exterior.xy plt.plot(x, y, c="red") plt.show()
Output
- Related Articles
- How do I plot hatched bars using Pandas and Matplotlib?
- How do I plot only a table in Matplotlib?
- How do I plot two countplot graphs side by side in Seaborn using Matplotlib?
- How do I plot a step function with Matplotlib in Python?
- How do I let my Matplotlib plot go beyond the axes?
- How do I plot multiple X or Y axes in Matplotlib?
- How do I change the axis tick font in a Matplotlib plot when rendering using LaTeX?
- How do I show logarithmically spaced grid lines at all ticks on a log-log plot using Matplotlib?
- How do I write a Latex formula in the legend of a plot using Matplotlib inside a .py file?
- How can I plot hysteresis threshold in Matplotlib?
- How do I redraw an image using Python's Matplotlib?
- How to plot collections.Counter histogram using Matplotlib?
- How do I make the width of the title box span the entire plot in Matplotlib?
- How do I plot a spectrogram the same way that pylab's specgram() does? (Matplotlib)
- How can I plot a confusion matrix in matplotlib?

Advertisements