21 votes
Accepted

Colorizing polygons based on color values in dataframe column?

The column= keyword can be used if you have values in a column which need to be mapped to a color (with a certain color map). But if you already have actual color names that you want to use directly, ...
joris's user avatar
  • 3,883
20 votes
Accepted

Plotting Shapely Multipolygon using Matplotlib

Shapely Polygon object has attribute exterior. Shapely MultiPolygon object has Polygon object sequence. You should iterate over those polygons. You can do that using attribute geoms of MultiPolygon. ...
Kadir Şahbaz's user avatar
19 votes

Change marker size in plot with GeoPandas

In geopandas >= 0.3 (released September 2017), the plotting of points is based on the scatter plot method of matplotlib under the hood, and this accepts a variable markersize. So now you can actually ...
joris's user avatar
  • 3,883
14 votes
Accepted

Plot shapefile on top of raster using plot and imshow from matplotlib

I added that recipe to the rasterio documentation. Since it was such a simple shape, in this case I just unzipped the coords in the single record contained by the shapefile. That is, x, y = zip(*...
jdmcbr's user avatar
  • 904
13 votes
Accepted

Center / normalize choropleth colors in GeoPandas

You could normalize the color by using the TwoSlopeNorm function in matplotlib. import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import TwoSlopeNorm import geopandas as gpd # ...
steven's user avatar
  • 348
13 votes

Plotting Shapely Multipolygon using Matplotlib

An alternative, shorter way of plotting using @Kadir Şahbaz's answer: Edit: Per @petezurich's comment, cascaded_union is superseded by unary_union as of 1.8.0 new_shape = so.unary_union([r1, r2, r3]) ...
decodering's user avatar
13 votes

Shapely deprecation warning message when plotting GeoPandas geodataframe

( Answer for users who ended up here based on the title and just want to hide the error ) If you have acknowledged the error and do not want it to keep appearing, you can always ignore it using : ...
user2589273's user avatar
13 votes
Accepted

Displaying GeoTIFF file in Python

Yes. It is just an issue related with the parameters. Without vmin and vmax, matplotlib uses nodata value as minimum value, and stretches the color map. So, you need to specify min and max value: ...
Kadir Şahbaz's user avatar
9 votes

Converting Matplotlib contour objects to Shapely objects

Issue with accepted answer: To complete the accepted answer, one should note that the method will fail if either of these is true: There is more than one polygon for a given level There are "holes" ...
nbeuchat's user avatar
  • 229
9 votes
Accepted

Geopandas Polygon to matplotlib patches Polygon conversion

There is a Python module for that: Descartes (look at Plot shapefile with matplotlib for example) from geopandas import GeoDataFrame test = GeoDataFrame.from_file('poly1.shp') test.set_index('id', ...
gene's user avatar
  • 54.7k
9 votes
Accepted

GeoPandas: plot two layers but only to the extent of the smaller one

You can set limits to the axis without chaining original GDF. import geopandas as gp import matplotlib.pyplot as plt from shapely.geometry import LineString, MultiPoint, Polygon thesmallpoints=gp....
martinfleis's user avatar
  • 2,387
7 votes
Accepted

Groupby Ploting - give each plot title/name

If you want to represent the continents side by side, you have to create subplots on the same fig. To do so, you can iterate through your group of continents. Here is an example: import geopandas as ...
Delforge's user avatar
  • 332
7 votes

Plotting multiple maps using GeoPandas

I usually plot multiple maps as following. import pandas as pd import geopandas as gpd import matplotlib.pyplot as plt fig, axs = plt.subplots(5, 5, figsize=(25, 25)) axs = axs.flatten() for idx in ...
AMA's user avatar
  • 414
6 votes

cartopy: plotting shapefiles

You can add edge or face color to the feature ax.add_feature(shape_feature, facecolor='blue')
tmthydvnprt's user avatar
6 votes
Accepted

Plotting large shapefiles with matplotlib

This is not a problem of Matplotlib but your script and the module you use for reading shapefiles 1) You know that there are points in the geometries of the Polygon shapefile thus eliminate try... ...
gene's user avatar
  • 54.7k
6 votes
Accepted

ArcMap crashing when plotting features with matplotlib few times via Python AddIn?

I think, It's most probably about Python GUI (especially Tkinter). Matplotlib uses Tkinter by default. I couldn't figure it out why, but If I change GUI package for matplotlib to PyQt4, no more ...
Kadir Şahbaz's user avatar
6 votes

Increasing resolution of Cartopy stock background?

It looks like cartopy package a downsampled version of the Natural Earth 'shaded relief and water' image as the stock image. You could try the original version (available here) and use ax.imshow to ...
tlrss's user avatar
  • 160
6 votes

Plotting Shapely Multipolygon using Matplotlib

Look at Plot shapefile with islands with matplotlib for example. As with polygons you can use matplotlib paths and patches and there is a Python module dedicated to plot polygons from shapefiles ...
gene's user avatar
  • 54.7k
6 votes

Plot a circle with a given radius around points on map using Python

What you want: Create a circle from the center of each marker This can be easily solved with geopandas buffer functions. You can see the description here. #make circle from point new_df = geo_df.copy()...
Urban87's user avatar
  • 616
6 votes
Accepted

How to change the font size of the color bar of a GeoPandas choropleth plot

It is a matplotlib problem and not a GeoPandas problem. See the solution of Seb Bacon: geopandas-legend-font-size.ipynb As the Jupyter notebook has problems (error opening it), I describe it here. ...
gene's user avatar
  • 54.7k
5 votes

Geopandas Polygon to matplotlib patches Polygon conversion

After the simple and understandable answer, I came up myself with a straightforward way to plot a whole shp with matplotlib. I feel geopandas should just update their plotting function because this ...
Philipp Schwarz's user avatar
5 votes
Accepted

Plotting raster maps in python?

I solved this problem. I was reading the raster file row-wise from top to bottom, and plotting it row-wise from bottom to top. Since, I can't do anything with plotting I flipped the array, and it ...
dsbisht's user avatar
  • 695
5 votes

DEM plot with matplotlib is too slow

Just to start, you could plot only a subset of the data. Maybe downsample by a factor of 4. Of course, you will need to think about resample method which would probably be bilinear in this case. ...
bcollins's user avatar
  • 3,563
5 votes

Reducing space in geopandas and matplotlib.pyplot's subplots?

The asker found their own answer: I got the answer: just reduce spaces in subplots_adjust as: fig.subplots_adjust(hspace=0.0, wspace=0.0)
PolyGeo's user avatar
  • 65.1k
5 votes
Accepted

Visualizing LAS with matplotlib

This is a working solution with laspy: import numpy as np import laspy from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt # reading las file and copy points input_las = laspy....
zwnk's user avatar
  • 390
5 votes
Accepted

Plotting shapely polygon with holes does not plot all holes

The reason is that exterior and interiors have a canonical form which assumes counter-clockwise coordinates for exterior and clockwise for interiors. You have to normalize your result to see it ...
martinfleis's user avatar
  • 2,387
5 votes
Accepted

Drawing a shape on an image with matplotlib

Look at What is meaning of scale on x and y axis of image using matplotlib A point vector shapefile (cartesian projection): import geopandas as gpd df = gpd.read_file("points.shp") df['x']...
gene's user avatar
  • 54.7k
5 votes
Accepted

Removing NaN value from legend in matplotlib map plotted from GeoPandas DataFrame

You should change column parameter from new_df["tmx_corrl"] to df_new["tmx_corrl"] in plot method. df_new.plot( ax=ax, column=df_new["tmx_corrl"], ## change here ...
Kadir Şahbaz's user avatar
5 votes

Displaying GeoTIFF file in Python

Following the comment from @mikewatt, when you imported with rasterio you kept the fill/nodata values (in your case, -3.4e+38) in the raster. This throws off the scale for imshow such that you can't ...
amelia's user avatar
  • 116
5 votes
Accepted

Overlay raster and vector using matplotlib and faceting

# I think is better If you use rasterio, plot and matplotlib # Look this code: import rasterio from rasterio import plot import geopandas as gpd import matplotlib.pyplot as plt ...
Helios's user avatar
  • 427

Only top scored, non community-wiki answers of a minimum length are eligible