Questions tagged [matplotlib]

If you are thinking about using this tag then perhaps reconsider whether your question would be better posted to Stack Overflow because "matplotlib is a python 2D plotting library" rather than GIS software.

Filter by
Sorted by
Tagged with
2
votes
1answer
45 views

Plotting multiple maps using GeoPandas

I have two GeoDataFrames. The first one have the administrative boundaries of the 25 regions of a country. The second one, the urban fabric of the same country. regions.head() COD NAMEREG ...
0
votes
1answer
50 views

Plotting: overlay raster on vector

I'm trying to create something like this: Which can be done in R using this guide: https://www.mzes.uni-mannheim.de/socialsciencedatalab/article/geospatial-data/ While I enjoy R I would like to know ...
1
vote
2answers
46 views

Plot shapely polygon on top of rasterio

I have 2D raster and I'm interested in plotting on top of it polygon. When I print the geometry and its' type I get this: #this is inside a loop that takes each time one row which is one polygon ...
0
votes
0answers
22 views

Plugin Import Error cannot load “WX” as “qt5” is currently running Ubuntu 21.04

Trying to import a self-written Plugin (works on other machines e.g. Windows) but I get an Import Error under Ubuntu 21.04 with QGIS 3.18: Cannot load backend 'WX' which requires the 'wx' interactive ...
2
votes
0answers
37 views

How can I plot a Kernel Density Estimation in a projected coordinate system in Python?

I am trying to plot a Kernel Density Estimation calculated from a geopandas GeoDataFrame in UTM. I am using sci-kit learn's KernelDensity, because other implementations don't allow for much ...
0
votes
0answers
45 views

Creating mask of geospatial data with maximum side-length(triangulation)

Earlier I asked a question, about Python GeoPandas crops result or sets boundary to data And I still cant understand how to work with geospatial data. I generate coordinates and create a plot with ...
1
vote
1answer
141 views

Python GeoPandas crops result or sets boundary to data

When I create GeoDataFrame from source data and then show it by pyplot all good, because I didn't do anything with the data. It looks like this: If I plot it with tricontourf, it looks like (errors ...
1
vote
1answer
140 views

Adding custom names to a GeoPandas legend

I have a shapefile which has an attribute table with a column I would like to make a map/plot of. The attribute values are numerical (integer). I have made two dicts to map the colors and names I want ...
0
votes
0answers
47 views

Creating plots for each hour of each day with Python

I am trying to create an animated map (by generating multiple plots) of road traffic throughout a week, where the thickness of roads is represented by the volume of traffic at a specific time of day. ...
0
votes
1answer
138 views

How to plot coordinate system from EPSG 4326 on north pole centered map in Python?

I have the following pandas dataframe (df) which looks like this with column headers and data values, 3 points each: temperature: array([-101.6015625, -100.9296875, -85.4296875]) latitude: array([32....
1
vote
3answers
50 views

Geopandas and Matplotlib Plotting error

I am trying to plot a point on top of a shapefile. the Coordinates of the point are accurate. I verified it using the go to XY tool of ArcMap. but when I try to plot overlay using Python the location ...
2
votes
1answer
39 views

Obtain CRS from existing axis with cartopy

Is there a method to get the CRS from a figure created with cartopy? Say for example, I only had access to the ax created here: import cartopy.crs as ccrs import matplotlib.pyplot as plt plt.figure(...
0
votes
0answers
53 views

Converting polygon to numpy array for CNN using Python

I need to create the current data set for CNN. So I want to convert the number entering a section of a certain area into a numpy array. For example, at the point where the geohash code is precision 6, ...
0
votes
0answers
48 views

How to rotate a Contextily basemap in matplotlib and Jupyter notebook

I asked this question on Stack Overflow because I thought the Jupyter Notebook and matplotlib aspects were better suited for that forum, but I didn't have any luck; it is also a geopandas and ...
3
votes
1answer
274 views

Matplotlib skip color for assigned interval in map plotted from GeoPandas DataFrame, if attribute don't have value in range of user defined bins

I have a GeoPandas GeoDataFrame which I am plotting against a specific column and the colour of the output/map is same for different assigned bins/intervals. The issue is because, sometimes, there is ...
2
votes
1answer
219 views

Legend colour not matching as assigned in the bins in matplotlib map plotted from GeoPandas DataFrame

I have a GeoPandas GeoDataFrame which I am plotting against a specific column and the colour of the output/map is not matching with the colour assigned to different bins/intervals. It should ideally ...
5
votes
1answer
249 views

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

I have a GeoPandas GeoDataFrame which I want to plot against a specific column. for day in days_list: df2 = csv_file[["state_id", "state_name", "tmx_corrl"]].loc[...
0
votes
0answers
26 views

Plotting contours for geodetic data.(in Python)

I need to plot contour plot for a geodetic dataset, but I have data for 15 locations of New Zealand. I have been able to generate a map a New Zealand using cartopy library of Python, but I am not sure ...
0
votes
1answer
1k views

Python Matplotlib Combine legend from histogram and lines [closed]

I wrote a Python script that uses matplotlib twinx to combine a histogram and some line functions plot as can see in the figure. However I was not capable of combining both legends (nb of points and ...
2
votes
1answer
2k views

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

When I try to use the legend_kwds argument to change the font size of my colorbar, I keep getting this error: TypeError: init() got an unexpected keyword argument 'fontsize' ax = df.plot(figsize=(20,...
3
votes
0answers
102 views

Opening plot window from PyQGIS processing script

I have this script which creates an elevation profile with annotated points in a matplotlib.pyplot window. It works perfectly in the console, but I want to add it to the QGIS toolbox so it can be run ...
0
votes
0answers
43 views

GeoPandas plot range problem

I read a .csv file with geometry like this: trajs = pd.read_csv("trajs.csv") trajs["geom"] = trajs["geom"].apply(wkt.loads) trajs = gpd.GeoDataFrame(trajs, geometry="...
1
vote
1answer
280 views

Rasterio doesn't show the coordinates when using “imshow ”

I have sentinel 2 image and I use rasterio to display it. I am using "imshow" to display it. when I display it, it doesn't show any coordinates: src=rasterio.open('14072020.tif') #Display ...
3
votes
1answer
443 views

Control histogram axis and legend with show_hist of rasterio

I have load raster (Sentinel 2) with Rasterio and I would like to create histogram of the pixels. The problem is that I beleive the graph gives automatically the X label and also the legend labels. ...
2
votes
1answer
317 views

Rasterio doesn't show the image in RGB

I have download raw landsat 8 image with Rasterio. The image was download from GEE. . The image has 11 bands. I'm trying to display the image with grey scale/color scale as DN values, but for some ...
1
vote
0answers
23 views

Getting the coordinates of the points inside of a shapefile/Getting the coordinates of the closest point if there are none

I'm working with an ERA5 (0.25x0.25 degree) temperature dataset for Europe in order to get average temperature in small statistical regions called NUTS 3. So far I've used a shapefile of the NUTS 3 ...
4
votes
1answer
323 views

Drawing a shape on an image with matplotlib

From a polygon shape I create a square buffer to create a sattelite image of my location. The shape is defined as a .shp file that I read with geopandas. I'd like to display the image AND the shape on ...
1
vote
1answer
926 views

Plotting shapely polygon with holes does not plot all holes

I'm trying to plot a filled shapely.geometry.Polygon polygon with holes in. I have tried 2 methods, both give the same result. Below is the code I have been using to debug from shapely.geometry import ...
2
votes
0answers
512 views

Colorbar with matplotlib and rasterio [closed]

I am having trouble generating a colorbar for two raster plots. I could not manage to install basemaps in my Mac so I am forced to use matplotlib. import rasterio from matplotlib import pyplot ...
1
vote
0answers
330 views

Error: shape mismatch when plotting certain DEM Geotiffs in 3D - using 'plot_surface' from Matplotlib

I'm trying to plot various DEM geotiff rasters in Python 3.7 using plot_surface in matplotlib but encountered an error that I can't solve. I have 2 DEM rasters, the small one plots correctly, the ...
6
votes
2answers
283 views

Adjusting edges around markers in legends in GeoPandas plot

I am trying to adjust the edges around the markers in my legend. Currently my code looks like this import matplotlib.pyplot as plt fig, ax = plt.subplots(figsize=(15,10)) lri_map.plot(column= '30', ...
3
votes
1answer
597 views

Overlapping legend: How to put geopandas legend next to the map?

I am using geopandas and contextily to plot building data (polygon) from OpenStreetMap. The problem is, the legend is overlapping the map. Is there any way to put the legend next to the map? or plot ...
0
votes
1answer
268 views

How to open a TIFF file created by Earth Engine with matplotlib

I'm using the Python API of GEE and I try to display my results in a PDF file. I'd like to create it with matplotlib so that I can check my figure before exportation. To add a little context : I ...
0
votes
0answers
81 views

Is it possible to display the embed color palette of a TIFF file using earthPy?

I try to display a map that I have created. This map embed a color palette that I can read in QGIS to obtain directly this kind of display : I discovered recently that I can as well directly plot ...
1
vote
1answer
195 views

Extract shapely polygon from matplotlib hexbin polycollection

I'm trying to extract all the vertices of hexagons that are returned from plt.hexbin. I then want to eventually convert them to shapely polygons, so I can use them with geopandas. At the moment I can ...
0
votes
1answer
527 views

Custom Colormap (cmap) rasterio, Python

I wish to display custom colours for the pixel values in my raster. How can I create a custom colormap (cmap)? In the example below, I have specified "magma" as the colour map. However, I ...
2
votes
1answer
5k views

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

I have created a map using GeoPandas with a few markers that represent some coordinates on the map. I want to do draw a circle around each marker with the marker placed in the center of the circle. ...
0
votes
1answer
1k views

How do I change the display size of a map from a shapefile with matplotlib?

I'm completely new to shapefiles. I was able to use GeoPandas to plot some data over a map of the US I got from census.gov. I'm having getting the map to be at a viewable size. I adjusted the figsize ...
0
votes
1answer
34 views

How to make graphs of latitude and longitude and generating summary table [closed]

I am not from geography. I am from quantitative finance. I want a graph with longitude and latitude of various locations of universities of my academic literature. And want to generate a summary table....
0
votes
0answers
53 views

OSM or Google Tile problem fitting to Geopandas Dataframe

I found this good post on how to get basemap tiles from open sources like OSM, Google, Bing, ESRI using python in geographic lat/long. I'm now trying to add the tiles I successfully got into a ...
2
votes
0answers
247 views

Plot polygon on rasterio window

I'm trying to plot several polygons on a raster. Several posts suggest to use matplotlib and descartes like this one: Plot shapefile on top of raster using plot and imshow from matplotlib My polygons ...
0
votes
0answers
82 views

When I get the total bounds of a shapefile, which are llcrnrlon, llcrnrlat, urcrnrlon, and urcrnrlat? Need it to use Maptlotlib Basemap

The goal is to use an ESRI webmap as a basemap beneath a shapefile for a script that visualizes earthquakes in the Philippines. But first, I'm practicing in using Basemap in a separate script. ...
0
votes
0answers
180 views

Plotting a csv file containing latitude and longitude into DEM (geotiff file)

I produced an elevation map. I want to plot my csv file named 'Coordinates.csv' that contains latitude and longitude points to my DEM (geotiff file) and the elevation map I produce will turn into ...
1
vote
1answer
25 views

How to combine labelling with limited boundingbox when plotting a geodataframe

I am trying to plot a limited boundingbox of my geodataframe setting up some x and y limits to the ax. Everything works but the labelling. This is my piece of code and current result: fig, ax = plt....
0
votes
1answer
654 views

geoplot: axis limits cannot be nan or inf

I am trying to plot a geodataframe with geoplot, and cannot work out the solution to ValueError: Axis limits cannot be NAN or Inf Context: Linux (Ubuntu 19.10, x86_64) cugdf.head(): Cu_ppm ...
1
vote
1answer
301 views

Changing CRS using GeoPandas in Python when print(file.crs) gives 'None'

I'm trying to change the .crs from a cylindrical projection (WGS84 (lat/lon)) to a Mercator-projection. Some information can be found here. However it doesn't seem to work for me for this shapefile ...
0
votes
1answer
72 views

Unable use a Temporal Plot Tool in GRASS GIS

I installed GRASS GIS following the tutorial on the website for the Ubuntu 18.04 version. However, the Temporal Plot Tool function is not working, and is giving an error related to python. Below is ...
1
vote
1answer
573 views

Rasterio histogram save as image

I have create some histogram using DEM as dataset and rasterio using show_hist to take histogram but I can't find some way to save this histogram as image.any idea? import rasterio from rasterio.plot ...
7
votes
3answers
12k views

Plotting Shapely Multipolygon using Matplotlib

I have few polygons or boxes. Ones intersect each other but some are isolated. For example I have free figures: import shapely.geometry as sg import shapely.ops as so import matplotlib.pyplot as plt ...
0
votes
1answer
616 views

Cut out selection of NetCDF4 file with shapely geometry

I have a ABI-L1b radiance file in the *.nc file format. I'm trying to cut out a selection of this file with a shapely polygon. I can plot both the netCDF4 file and polygon but I am unsure of how to ...