matplotlib-basemap

Plotting Lat/Long Points Using Basemap

浪子不回头ぞ 提交于 2019-12-05 02:14:26
问题 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

How to set the label Fonts as “Time New Roman” by drawparallels in python

末鹿安然 提交于 2019-12-05 00:26:31
问题 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) 回答1: You need to set font family using pyplot of matplotlib . import matplotlib.pyplot as plt csfont = {'fontname':'Times New Roman'} // write your code related to basemap here plt.title('title',**csfont) plt.show() You can also use the following to change font globally. import matplotlib.pyplot as plt plt.rcParams["font

Get PyInstaller to import Basemap

戏子无情 提交于 2019-12-04 14:22:56
问题 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

Why is matplotlib basemap not plotting the colours of some areas in my map?

荒凉一梦 提交于 2019-12-04 14:19:43
The code below is supposed to colour all the states of Vietnam: import pandas as pd import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap fig, ax = plt.subplots(figsize=(10,20)) # create the map map = Basemap(resolution='l', # c, l, i, h, f or None projection='merc', lat_0=15.95, lon_0=105.85, llcrnrlon=102., llcrnrlat= 8.31, urcrnrlon=109.69, urcrnrlat=23.61) # load the shapefile, use the name 'states' map.readshapefile(r'path\to\gadm36_VNM_1', name='states', drawbounds=True) # shapefile downloaded from http://www.gadm.org/ # collect the state names from the shapefile

basemap ImportError: No module named 'mpl_toolkits.basemap'

我只是一个虾纸丫 提交于 2019-12-04 14:09:41
from mpl_toolkits.basemap import Basemap gives ImportError: No module named 'mpl_toolkits.basemap' I installed basemap with conda wayne@dors:~$ conda install basemap Solving environment: done # All requested packages already installed. I am running ubuntu 15.04, Python3.4, matplotlib 2.1.1, numpy 1.8.2 How do I fix? ConfusedMan Try to install it with this command: conda install -c conda-forge basemap "Only the 'crude' and 'low', resolution datasets are installed by default" .You may need to install the following for high resolution: conda install -c conda-forge basemap-data-hires I think you

Pyplot contour plot - clabel spacing

*爱你&永不变心* 提交于 2019-12-04 11:45:24
问题 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

Python Interpolation with matplotlib/basemap

岁酱吖の 提交于 2019-12-04 11:17:50
I am rather new to programming and am having a very hard time understanding interpolation. Every single source I can find that attempts to explain it is extremely cryptic (especially the package specific sites for basemap/matplotlib). I am mapping using matplotlib's basemap however the nature of my data is that it comes in 5 degree by 5 degree blocks (lat lon blocks). I want to smooth out the map by interpolation. So first here is my code. from netCDF4 import Dataset import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap, addcyclic #load the netcdf file

Animation of pcolormesh() with mpl_toolkit.basemap giving attribute error

人盡茶涼 提交于 2019-12-04 10:18:07
I am trying to animate some density data on a basemap map. Following an approach as was done in [this SO question][1], I get the following error: /usr/local/lib/python2.7/dist-packages/matplotlib/collections.pyc in update_scalarmappable(self) 627 if self._A is None: 628 return --> 629 if self._A.ndim > 1: 630 raise ValueError('Collections can only map rank 1 arrays') 631 if not self.check_update("array"): AttributeError: 'list' object has no attribute 'ndim' If I instead set the data in init() with null values by self.quad.set_array(self.z.ravel()) , I end up with two plotted maps with no data

Plotting oceans in maps using basemap and python

不想你离开。 提交于 2019-12-04 07:31:09
I am plotting the netCDF file available here: https://goo.gl/QyUI4J Using the code below, the map looks like this: However, I want the oceans to be in white color. Better still, I want to be able to specify what color the oceans show up in. How do I change the code below to do that? Right now, the issue is that the oceans are getting plotted on the data scale. (please note that the netCDF file is huge ~3.5 GB). import pdb, os, glob, netCDF4, numpy from matplotlib import pyplot as plt from mpl_toolkits.basemap import Basemap def plot_map(path_nc, var_name): """ Plot var_name variable from

How to draw circle in basemap or add artiste

牧云@^-^@ 提交于 2019-12-04 05:36:25
问题 I want to know how can i plot a circle with Basemap using latitude and longitude. import matplotlib.pyplot as plt fig,ax = plt.subplots() ax.axis([0,10,0,10]) circle1 = plt.Circle((5, 5), 2, color='black',fill=False) x = ax.add_artist(circle1) plt.show() I want to do the same but with x,y,radius as lon lat in my basemap graph from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt m = Basemap(projection="mill", #miller est une projection connu llcrnrlat =0,#lower left corner