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
0
votes
0answers
11 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
78 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 ...
1
vote
1answer
47 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 ...
4
votes
1answer
43 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
15 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
108 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 ...
1
vote
1answer
316 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
49 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
35 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="...
0
votes
1answer
59 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
101 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. ...
1
vote
1answer
83 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
16 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
114 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
290 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
188 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
139 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 ...
5
votes
1answer
111 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', ...
2
votes
1answer
136 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
90 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
36 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
73 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
204 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 ...
1
vote
1answer
2k 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
232 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
27 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
36 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 ...
1
vote
0answers
137 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
32 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
91 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 ...
0
votes
0answers
33 views

Displaying a multi-band raster using Rasterio and Matplotlib

I am attempting to visualize a raster a 4-band (RGB+NIR, stacked) Sentinel-2 raster using Rasterio and Matplotlib in Python, and getting an unusual image. Here is the code so far: import matplotlib....
1
vote
1answer
22 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
0answers
17 views

Plotting Truncated Month Range in PyPlot

I am working to plot a DataFrame where rows are specified as yyyy-mm-dd values and have successfully plotted them as shown. The data is being plotted against individual month ticks but I want to ...
0
votes
1answer
352 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 ...
0
votes
0answers
68 views

Ploting a GeoDataframe in Python

I'm trying to plot a geodataframe in python using Pycharm IDE but the result of the operation is a white vaccum plot. When i try to do the same operation with a colab notebook it works. Any ...
1
vote
1answer
158 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
61 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
297 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 ...
4
votes
3answers
6k 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
300 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 ...
0
votes
1answer
152 views

Python surface plot in QGIS

I'm new in QGIS and I’m having some troubles. I have produced a surface plot in python and I would like to import it in QGIS but I don't know how do that, can anyone help me? P.S. I also have the ...
0
votes
1answer
107 views

What is meaning of scale on x and y axis of image using matplotlib

I am finding elevation of a region using richdem. Can somebody tell me what is the meaning of the scale which is on the x and y axis of the image? import os import numpy as np import matplotlib ...
1
vote
0answers
358 views

Displaying projection with IMSHOW()

I am having an issue displaying satellite data on the correctly projection using cartopy and imshow. I am unsure of the initial data projection, but I am trying to put it into Plate Carree with a ...
1
vote
0answers
101 views

Single country coastlines in Python Matplotlib Cartopy

In the image below I am using cartopy to plot coastlines. But, I only wish to have the coastlines of Australia, and not the surrounding countries. Is there a way to remove the other countries. Here ...
0
votes
1answer
596 views

Plot shapefile with islands with matplotlib

I am trying to plot a city shapefile with matplotlib's plt.plot()-function. However, within the closed areas I occasionally have small "islands" which lie within the city but not part of it. Therefore ...
1
vote
1answer
607 views

Plot RGB using rasterio

When plotting and RGB image using rasterio, I have seen that it is necessary to normalize the values first (0-1) and the use show. I am using the following code for that: def norm(band): band_min,...
3
votes
0answers
321 views

Add WMS to matplotlib Python

Currently I am adding a basemap from stamen.com to my plots as it is explained here: http://geopandas.org/gallery/plotting_basemap_background.html . Is it also possible to load a WMS from another ...
6
votes
3answers
4k views

Colorizing polygons based on color values in dataframe column?

I preparing some choropleth election result maps in Geopandas. The assigned color for each electoral district must correspond with the winning party (a color that I pre-determine), and the intensity ...
1
vote
0answers
348 views

Plotting TIFF File on tkinter Canvas

I have a TIFF file which I am trying to plot on tkinter canvas using the following code: import tkinter from matplotlib.backends.backend_tkagg import ( FigureCanvasTkAgg, NavigationToolbar2Tk) # ...
1
vote
2answers
3k views

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

I am using GeoPandas and I want to plot two layers. I want the map to have the extent of the smaller layer. With this code below, the map's size automatically fits the bigger layer. import geopandas ...