matplotlib-basemap

`map.scatter` on basemap not displaying markers

时光怂恿深爱的人放手 提交于 2019-12-04 03:56:50
问题 I have a map of Germany, and the coords of a few cities. plot displays the dots properly. I would like to use scatter instead, in order to be able to color the markets with respect to an other variable and then display a colorbar . The code runs in the console, but the dots are not visualized when I replace map.plot with map.scatter . from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np plt.figure(1) map = Basemap(projection='merc', resolution='l',

Why do I get “UserWarning: Module dap was already imported from None …”

女生的网名这么多〃 提交于 2019-12-04 00:39:04
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 this warning: >>> import mpl_toolkits.basemap /usr/lib/pymodules/python2.7/mpl_toolkits/__init__.py:2: UserWarning: Module dap was already imported from None, but /usr/lib/python2.7/dist-packages is being added to sys.path __import__('pkg_resources').declare_namespace(__name__) Does this mean I have 2 conflicting installs of dap ? (That might be possible, remnants of some old manual installs.) Here

Plotting Lat/Long Points Using Basemap

浪尽此生 提交于 2019-12-03 20:14:24
I am trying to plot points on a map using matplotlib and Basemap, where the points represent the lat/long for specific buildings. My map does indeed plot the points, but puts them in the wrong location. When I use the same data and do the same thing using Bokeh, instead of matplotlib and basemap, I get the correct plot. Here is the CORRECT result in Bokeh: Bokeh Version And here is the INCORRECT result in Basemap: Basemap Version I have seen discussion elsewhere on StackOverflow that suggested this might be related to the fact that plot() "shifts" the longitude somehow. I've tried the

Basemap readshapefile ValueError

回眸只為那壹抹淺笑 提交于 2019-12-03 17:37:58
I downloaded a map from US Census in shapefile format. It has all the required information that I need, but for som reason there's a specific map that I need it's giving me this error: Traceback (most recent call last): File "C:/Users/Leb/Desktop/Python/Kaggle/mapp.py", line 17, in <module> shp_info = m.readshapefile('gis/cb_2014_us_state_5m', 'states', drawbounds=True) File "C:\Program Files\Python 3.5\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 2162, in readshapefile raise ValueError('readshapefile can only handle 2D shape types') ValueError: readshapefile can only handle 2D

Force use of scientific style for basemap colorbar labels

笑着哭i 提交于 2019-12-03 16:10:11
String formatting can by used to specify scientific notation for matplotlib.basemap colorbar labels: cb = m.colorbar(cs, ax=ax1, format='%.4e') But then each label is scientifically notated with the base. If numbers are large enough, the colobar automatically reduces them to scientific notation, placing the base (i.e. x10^n ) at the top of the color bar, leaving only the coefficient numbers as labels. You can do this with a standard axis with the following: ax.ticklabel_format(style='sci', axis='y', scilimits=(0,0)) Is there an equivalent method for matplotlib.basemap colorbars, or perhaps a

How to animate matplotlib's drawgreatcircle function?

强颜欢笑 提交于 2019-12-03 13:51:16
I have created a small program which takes an NHL city and then draws the path the team travels throughout their season. The resulting graphic is messy: So I got the idea that it would be interesting if I animated the flight paths, sort of like watching an Indiana Jones movie, where the line grows from one point to another. My understanding from looking at other matplotlib samples is that the animation function takes in a function, calculates it's output, and then updates the graphic. I don't see how this would be possible with drawgreatcircle since whenever I call it I am given a completed

Get PyInstaller to import Basemap

那年仲夏 提交于 2019-12-03 09:54:41
I'm working on building a standalone executable for a simple tool I built that uses Basemap. (Using Python 2.7, using the dev version of PyInstaller - 2.1). The .exe (single file) builds just fine, but when it runs, I get the following error: Traceback <most recent call last>: File "<string>", line 9, in <module> File "c:\python27\lib\site-packages\PyInstaller-2.1dev_-py2.7.egg\PyInstaller\loader\pyi_importers.py", line 270, in load_module exec<bytecode, module.__dict> File "C:\Documents and Settings\MYNAME\Python code\Flood\src\root\nested\build\FloodRisk\out00-PYZ.pyz\mpl_toolkits.basemap",

Pyplot contour plot - clabel spacing

ぐ巨炮叔叔 提交于 2019-12-03 08:09:30
I have trouble with matplotlib / pyplot / basemap. I plot contour lines (air pressure) on a map. I use clabel to show the value of the contour lines. But the problem is: the padding between the value and the contour line is too much. I have found the parameter "inline_spacing", which i have set to zero. But there is still to much free space. Any ideas? Python Code: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap import pygrib filename = "file.grib2" grbs = pygrib.open('/data/' + filename) grb = grbs[2] data = grb.values datac =

world map without rivers with matplotlib / Basemap?

你说的曾经没有我的故事 提交于 2019-12-03 03:47:14
问题 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 River, not even reaching the ocean, is disturbing. EDIT: I intend to further plot data over the map, like in the Basemap gallery (and still have the borderlines of the continents drawn as black lines over the data, to give structure for the worldmap) so while the solution by Hooked below is nice,

use of matlab meshgrid

早过忘川 提交于 2019-12-02 18:08:30
问题 Sorry i have to keep coming back to the problem gridding irregularly spaced data. I do not seem to see any clear responses to questions of how to grid data to a regular grid and the software documentation to me is good for those who already know. I have x, y, z data on 29 points, with a header "Lon Lat Z". to plot contours with this data here is what I do: After reading in the data, make a 300 by 300 point regular grid onto which to interpolate numcols, numrows = 300, 300 xi = np.linspace