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.

Filter by
Sorted by
Tagged with
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") ...
jseabold's user avatar
  • 8,213
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/...
Arnaud BUBBLE's user avatar
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): ...
Yupei's user avatar
  • 411
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 ...
phasselmann's user avatar
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-...
msunbot's user avatar
  • 1,941
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 ...
Prikers's user avatar
  • 958
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 ...
Levi Cowan's user avatar
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 ...
HyperCube's user avatar
  • 3,920
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 ...
pceccon's user avatar
  • 9,634
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 ...
Behnam's user avatar
  • 511
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??
red_tiger's user avatar
  • 1,432
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 ...
Cebbie's user avatar
  • 1,789
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)
Wang Tao's user avatar
  • 233
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 ...
Sampo Smolander's user avatar
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....
Timi's user avatar
  • 892
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 ...
MomoPP's user avatar
  • 599
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 ...
2964502's user avatar
  • 4,381
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....
Mattijn's user avatar
  • 13.5k
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 ...
Nitin's user avatar
  • 2,744
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 ...
r4gt4g's user avatar
  • 304
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 ...
HyperCube's user avatar
  • 3,920
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'...
mikez1's user avatar
  • 685
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 (...
andreas-h's user avatar
  • 10.9k
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 ...
RubenB's user avatar
  • 141
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 ...
Sampo Smolander's user avatar
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:/...
tommy.carstensen's user avatar
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 ...
Klausos Klausos's user avatar
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/...
peter's user avatar
  • 315
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 ...
iury simoes-sousa's user avatar
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 ...
ZYX's user avatar
  • 804
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, ...
Martin Thoma's user avatar
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 ...
Geena's user avatar
  • 111
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 ...
leroygr's user avatar
  • 2,449
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 ...
MichaelDeSanta's user avatar
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 ...
Jorrit G's user avatar
  • 589
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 ...
Zilore Mumba's user avatar
  • 1,420
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,...
2964502's user avatar
  • 4,381
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 ...
sundar_ima's user avatar
  • 3,788
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. ...
samy's user avatar
  • 113
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 ...
Trond Kristiansen's user avatar
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,...
red_tiger's user avatar
  • 1,432
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 ...
user2607622's user avatar
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.....
Noise in the street's user avatar
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 ...
javaEd's user avatar
  • 158
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....
Ella's user avatar
  • 93
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?
Andy Stow Away's user avatar
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 ...
user3644627's user avatar
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 ...
jrb0042's user avatar
  • 71
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 ...
Teachey's user avatar
  • 549
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, ...
Maria Koroliuk's user avatar

1
2 3 4 5
26