matplotlib-basemap

How to plot the grid line only using pcolor/pcolormesh

无人久伴 提交于 2019-12-06 03:20:59
By using ax.axhline & ax.axvline I can plot the grid network shows like this: http://i4.tietuku.com/e90652c9a56b5e61.png the code are reproduced here: lon_grid = np.linspace(113.5,115.49,36) lat_grid = np.linspace(37.40,38.78,30) lon_grid,lat_grid = np.linspace(xc1,xc2,36), np.linspace(yc1,yc2,30) for i in range(0,len(lon_grid),1): ax.axvline(x=lon_grid[i], linestyle='-', color='black', linewidth=0.75, zorder=3) for i in range(0,len(lat_grid),1): ax.axhline(y=lat_grid[i], linestyle='-', color='black', linewidth=0.75, zorder=3) Here is my question Can I use pcolor/pcolrmesh to just draw the

Plotting oceans in maps using basemap and python

有些话、适合烂在心里 提交于 2019-12-06 02:33: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

Fill oceans in basemap [duplicate]

牧云@^-^@ 提交于 2019-12-05 22:22:46
This question already has an answer here: Plot only on continent in matplotlib 5 answers I am trying to plot 1x1 degree data on a matplotlib.Basemap , and I want to fill the ocean with white. However, in order for the boundaries of the ocean to follow the coastlines drawn by matplotlib , the resolution of the white ocean mask should be much higher than the resolution of my data. After searching around for a long time I tried the two possible solutions: (1) maskoceans() and is_land() functions, but since my data is lower resolution than the map drawn by basemap it does not look good on the

Plotting a map with matplotlib basemap - horribly slow

只愿长相守 提交于 2019-12-05 20:52:20
Plotting a very, very simple map of only europe in matplotlib / basemap takes so much time ( around 10 seconds! ). This is just unreal!? Setting of resolution is only "l" (low). Here is the very simple code: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap m = Basemap(projection='stere',lon_0=5,lat_0=90.0,rsphere=6371200.,\ llcrnrlon=-25.0,urcrnrlon=72.0,llcrnrlat=26.0,urcrnrlat=65.0,resolution='l') m.drawcoastlines(linewidth=0.2) m.drawcountries(linewidth=0.2) plt.savefig('/var/www/map.png') I need to plot hundreds of these maps

How to plot geolocated RGB data faster using Python basemap

雨燕双飞 提交于 2019-12-05 14:53:43
I'm having an issue plotting an RGB image using Python's Basemap module with latitude and longitude data. Now, I am able to make the plots that I want, but the problem is how slow it is, since it is able to plot single channel data much faster than the RGB data, and in general, plotting RGB images on their own is also fast. Since I have lat/lon data, that is where things get complicated. I've checked out the solution to this problem: How to plot an irregular spaced RGB image using python and basemap? which is how I got to where I am right now. It essentially comes down to the following issue.

How can I create a discrete colorbar using a colormap from mpl_toolkits.basemap.cm?

纵饮孤独 提交于 2019-12-05 14:10:12
When I plot the pcolormesh plot use the colormap from matplotlib.cm (like "jet" , "Set2" , etc), I can use: cMap = plt.cm.get_cmap("jet",lut=6) The colorbar shows like this: But if I want to call the colormap from the Basemap package (like GMT_drywet , GMT_no_green , etc). I can't use plt.cm,get_cmap to get these colormap and divide them. Does mpl_toolkits.basemap.cm have a similiar function like lut ? As long as the plot you are making has discrete color values (e.g. contour or contourf ), then colorbar should automatically generate a colorbar with discrete steps. Here's a plot based on the

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

China☆狼群 提交于 2019-12-05 14:03:59
问题 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

Scipy map_coordinates bilinear interpolation compared to interp and IDL interpolate

梦想的初衷 提交于 2019-12-05 11:34:58
I'm in the process of rewriting a coworkers IDL code into python and am coming up with some differences that I'm confused about. According to other SO questions and mailing list threads I've found if you use scipy.ndimage.interpolation.map_coordinates and specify order=1 it is supposed to do bilinear interpolation. When comparing results between the IDL code (run in GDL) and python (map_coordinates) I got different results. Then I tried using mpl_toolkits.basemap.interp and I got the same result as the IDL code. Below is a simple example that shows what is wrong. Could someone help me figure

Plotting a Map with geopy and matplotlib in Jupyter Notebook

我与影子孤独终老i 提交于 2019-12-05 08:08:19
问题 I am trying to plot a map of the US and mark the various cities across the country. I got the map to work. But I am having two issues: the first is, I am getting this error message: AttributeError: 'NoneType' object has no attribute 'longitude' Secondly, I have tried to enlarge the graph using the plt.figsize attribute however my map still stays the same size. Lastly, this is not really an issue but what if i wanted to label the dots with the city names How can i do so? Here is my code for

Basemap readshapefile ValueError

。_饼干妹妹 提交于 2019-12-05 02:44:51
问题 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