Questions tagged [matplotlib-basemap]
The matplotlib basemap toolkit is a library for plotting 2D data on maps in Python. It is similar in functionality to the matlab mapping toolbox, the IDL mapping facilities, GrADS, or the Generic Mapping Tools. PyNGL and CDAT are other libraries that provide similar capabilities in Python.
1,251
questions
51
votes
7
answers
13k
views
why does my colorbar have lines in it?
Edit: Since this seems to be a popular post, here's the solution that seems to be working well for me. Thanks @gazzar and @mfra.
cbar.solids.set_rasterized(True)
cbar.solids.set_edgecolor("face")
...
48
votes
18
answers
140k
views
Python basemap module impossible to import
I have troubles to import the basemap module of mpl_toolkits in python. Here is what I get when I run the test.py script from the module directory:
/usr/lib/python2.7/dist-packages/mpl_toolkits/...
33
votes
10
answers
36k
views
Basemap import error in PyCharm — KeyError: 'PROJ_LIB'
I tried to use Basemap package to plot a map by PyCharm, but I got something wrong with
from mpl_toolkits.basemap import Basemap`
And the Traceback as followed:
Traceback (most recent call last):
...
32
votes
5
answers
19k
views
Is it possible to control matplotlib marker orientation?
If I have a triangular marker, is it possible to control its orientation? I have a series of facets, with their corresponding vertices, and I would like to plot a basemap of them. I know it is ...
29
votes
6
answers
29k
views
OSError geos_c could not be found when Installing Shapely [duplicate]
I'm a newbie to making/plotting on maps with python, been trying to follow this blogpost to generate a world map ( http://sciblogs.co.nz/seeing-data/2011/08/12/plotting-geographic-data-on-a-world-map-...
28
votes
6
answers
50k
views
Basemap with Python 3.5 Anaconda on Windows
I use Python 3.5 with latest version of Anaconda on Windows (64 bit). I wanted to install Basemap using conda install basemap. Apparently there is a conflict between Python 3 and basemap. After some ...
27
votes
2
answers
19k
views
Python Matplotlib Basemap overlay small image on map plot
I am plotting data from an aircraft on a map and I would like to insert this 75px by 29px PNG image of an airplane at the coordinates of the latest data point on the plot.
As far as I know and have ...
26
votes
2
answers
32k
views
Draw polygons more efficiently with matplotlib
I have a dateset of around 60000 shapes (with lat/lon coordinates of each corner) which I want to draw on a map using matplotlib and basemap.
This is the way I am doing it at the moment:
for ii in ...
24
votes
6
answers
33k
views
Installing basemap on Mac / Python
I'm having trouble to get the basemap to work in Python in my Mac.
I keep receiving:
from mpl_toolkits.basemap import basemap
ImportError: No module named basemap
What I did:
brew install gdal
...
24
votes
2
answers
43k
views
How to insert scale bar in a map in matplotlib
Any ideas on how can I insert a scale bar in a map in matplotlib that shows the length scale? something like the one I have attached.
Or maybe any ideas on measuring and showing distances ...
24
votes
3
answers
35k
views
Fill countries in python basemap
Hi I am trying to plot a map using pythons basemap with some countries filled in a certain colour.
Is there a quick and easy solution out there??
24
votes
1
answer
37k
views
How to smooth by interpolation when using pcolormesh?
I have a basemap of the world, and it's filled with data (lintrends_mean) using pcolormesh. Because the data has relatively large grid boxes, I'd like to smooth the plot. However, I can't figure out ...
23
votes
1
answer
108k
views
How to set the label Fonts as "Time New Roman" by drawparallels in python
I have draw a map with latitudes labelled but I want to set the fonts as "Times New Roman". How to make it possible?
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=12)
20
votes
7
answers
15k
views
world map without rivers with matplotlib / Basemap?
Would there be a way to plot the borders of the continents with Basemap (or without Basemap, if there is some other way), without those annoying rivers coming along? Especially that piece of Kongo ...
20
votes
2
answers
55k
views
What names can be used in plt.cm.get_cmap?
I have this code :
plt.scatter(data_projected[:,0],data_projected[:,1],c=digits.target
,edgecolors='none',alpha=0.5,cmap=plt.cm.get_cmap('nipy_spectral',10));
My confusion comes from plt....
19
votes
3
answers
37k
views
How to use Basemap (Python) to plot US with 50 states?
I am aware that the powerful package Basemap can be utilized to plot US map with state boundaries. I have adapted this example from Basemap GitHub repository to plot 48 states colored by their ...
17
votes
3
answers
33k
views
draw grid lines over an image in matplotlib
How can I draw regular grid lines over a tiff image?
I want to draw regular square grids for each interval (say 100 by 100 pixels) over the image and save that with the drawings. I also need to ...
17
votes
1
answer
17k
views
Plot GDAL raster using matplotlib Basemap
I would like to plot a raster tiff (download-723Kb) using matplotlib Basemap. My raster's projection coordinates is in meter:
In [2]:
path = r'albers_5km.tif'
raster = gdal.Open(path, gdal....
17
votes
2
answers
18k
views
Drawing a graph with NetworkX on a Basemap
I want to plot a graph on a map where the nodes would be defined by coordinates (lat, long) and have some value associated.
I have been able to plot points as a scatterplot on a basemap but can't ...
16
votes
2
answers
24k
views
How to Install Matplotlib Basemap Module on Windows 7 with WinPython (or any Python stack install)?
I've found that the Basemap (module for matplotlib and Python) binary installer for Windows cannot detect Python on the system when Python is installed as part of a stack install, like Anaconda or ...
16
votes
3
answers
4k
views
Eliminate white edges in Matplotlib/Basemap pcolor plot
I am plotting data on a map using this code:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from mpl_toolkits.basemap import Basemap
from ...
15
votes
3
answers
77k
views
How to make grouper and axis the same length?
For my assignment I'm supposed to plot the tracks of 20 hurricanes on a map using matplotlib. However when I run my code I get the error: AssertionError:Grouper and axis must be the same length
Here'...
15
votes
4
answers
24k
views
How to draw rectangles on a Basemap
I'm looking for a way to plot filled rectangles on a Basemap. I could easily draw the rectangle's edges using the drawgreatcircle method, but I cannot find a way to actually fill these rectangles (...
14
votes
5
answers
12k
views
Basemap library using Anaconda Jupyter Notebooks - KeyError: PROJ_LIB
I'm trying to install and import the Basemap library into my Jupyter Notebook, but this returns the following error:
KeyError: 'PROJ_LIB'
After some research online, I understand I'm to install ...
14
votes
3
answers
12k
views
Why do I get "UserWarning: Module dap was already imported from None ..."
I have python-matplotlib and python-mpltoolkits.basemap installed from Ubuntu packages. Installing python-mpltoolkits.basemap also installs python-dap as a dependency.
When I import basemap, I get ...
14
votes
2
answers
2k
views
color matplotlib map using bicubic interpolation
I know that matplotlib and scipy can do bicubic interpolation:
http://matplotlib.org/examples/pylab_examples/image_interp.html
http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html
http:/...
13
votes
5
answers
71k
views
How to install Matplotlib's basemap?
It is unclear to me how to install Matplotlib's Basemap on Windows. Maybe the question is straightforward, I need some help.
I followed this tutorial. As far as I understand, first, GEOS and PROJ4 ...
13
votes
4
answers
11k
views
Python Basemap Import error: "requirement already satisfied" [duplicate]
What works is
import mpl_toolkits
What not works is (Import Error basemap not found)
from mpl_toolkits.basemap import Basemap
I followed the instructions here :
http://matplotlib.org/basemap/users/...
12
votes
6
answers
35k
views
How to use OpenStreetMap background on Matplotlib Basemap
This should be simple, but when I look for it I just find web packages. I need something better than as oriented on This Blog. Maybe using .oms file or shapefiles. Some way to give bbox and get the ...
12
votes
5
answers
9k
views
Plot only on continent in matplotlib
I am drawing a map using basemap from matplotlib. The data are spreaded all over the world, but I just want to retain all the data on the continent and drop those on the ocean. Is there a way that I ...
12
votes
2
answers
18k
views
How can I install Basemap in Python 3 / Matplotlib 2 on Ubuntu 16.04?
I tried
pip3 install basemap
but Basemap seems not to be on PyPI.
There is an old question but it has no answer.
What I did
I downloaded basemap 1.07 (source)
Matplotlib 2, numpy 1.11, PIL, ...
11
votes
8
answers
48k
views
Importing mpl_toolkits.basemap on Windows?
I have recently started using Python 3.5 and Anaconda on my Windows pc. I am trying to plot a map. However, When I am in my Jupyter notebook and i type the command
import mpl_toolkits.basemap
I get ...
11
votes
2
answers
26k
views
Matplotlib: draw a selection area in the shape of a rectangle with the mouse
I want to be able to draw a selection area on a matplotlib plot with a mouse event. I didn't find information on how to do it with python.
In the end, I want to be able to draw a region of interest ...
10
votes
1
answer
10k
views
How to plot 3D Earth in Python?
I'm trying to plot a satellite orbit around the Earth. This is what I currrently have:
I made this plot using the Axes3D function in mpl_toolkits.mplot3d. Ideally what I would like to do, is to ...
9
votes
4
answers
17k
views
Maplotlib and Basemap: cannot import name 'dedent'
I'm trying to draw a network on a basemap overlay.
I have packages:
basemap=1.3.0=py36ha7665c8_0
matplotlib=3.3.1=0
matplotlib-base=3.3.1=py36hba9282a_0
networkx=2.5=py_0
When I run only the line
...
9
votes
2
answers
12k
views
How can I get my contour plot superimposed on a basemap
This is a question I asked several months ago and am still struggling to come to a solution. My code gives me a basemap and a contour plot side by side (but printing to file only gives the contour ...
9
votes
1
answer
8k
views
using scalebar in matplotlib basemap
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
m = Basemap(projection='cyl',resolution='c',area_thresh=10,llcrnrlon=-180,urcrnrlon=180,\
llcrnrlat=-90,...
8
votes
2
answers
10k
views
How to remove/omit smaller contour lines using matplotlib
I am trying to plot contour lines of pressure level. I am using a netCDF file which contain the higher resolution data (ranges from 3 km to 27 km). Due to higher resolution data set, I get lot of ...
8
votes
2
answers
8k
views
Add transparent picture over plot
My python script below adds a picture (a generated rectangle on this simple example) and GPS track on a map generated with Basemap module.
Now I would like to make both track an rectangle transparent. ...
8
votes
1
answer
6k
views
Contour irregular data within polygon
I need to create filled contour plots of sea surface temperature (SST) data within a polygon, however I am not sure the best way to do this. I have three 1D arrays containing data for X, Y, and SST ...
8
votes
3
answers
2k
views
Python basemap stereographic map
I want to display some values on a stereographic map (in this case southpole (spstere)). If I display them on a cylindric map (cyl) everything is fine:
m = Basemap(projection='cyl',llcrnrlon=-180,...
8
votes
1
answer
3k
views
Mask area outside of imported shapefile (basemap/matplotlib)
I'm plotting data on a basemap of the eastern seaboard of the U. S. and Canada through Matplotlib. In addition to the base layer (a filled contour plot), I overlayed a shapefile of this focus region ...
8
votes
1
answer
2k
views
Using Python to plot Natural Earth shapes as polygons in Matplotlib Basemap
I'm close to getting the map that I want. Matplotlib's Basemap is great, but the coastlines are too coarse when I zoom in. I can read the Natural Earth shapefiles and plot them, which are much better.....
8
votes
2
answers
3k
views
Python GUI from Java
I am working on a program which takes a user input and generates an output as a map projection plot.
The easiest map projection library that I have found is matplotlib-basemap, written in python a ...
8
votes
1
answer
1k
views
Installation Error: installing basemap on windows
I'm trying to install basemap, and it seems worked fine using,
conda install -c conda-forge basemap
in anaconda prompt. However when I entered this code on my jupyternotebook,
import matplotlib....
7
votes
1
answer
7k
views
Matplotlib basemap: Popup box
I want to know how to create a popup box in a basemap plot. When I hover my mouse over a location , it should trigger the popup box.
Is this possible?
7
votes
1
answer
7k
views
3D CartoPy similar to Matplotlib-Basemap
I'm new to Python with a question about Cartopy being able to be used in a 3D plot. Below is an example using matplotlibBasemap.
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import ...
7
votes
3
answers
18k
views
Problems installing/importing Basemap
I have installed Anaconda (version 1.6.2) installed on my 64 bit machine. It comes with a great set of libraries, but I also need Basemap, part of matlibplot, but it is not included with the Anaconda ...
7
votes
1
answer
1k
views
Cartesian projection issue in a FITS image through PyFITS / AstroPy
I've looked and looked for a solution to this problem and am turning up nothing.
I'm generating rectangular FITS images through matplotlib and subsequently applying WCS coordinates to them using ...
7
votes
1
answer
2k
views
How to make sure text title is inside the polygon object?
I am making a map plot, where I want to put a small text label inside every state. My current problem is that the text goes outside the state limits, so it doesn't look nice:
I tried using mean, ...