matplotlib-basemap

Scatter does not plot any points on Basemap

自作多情 提交于 2019-12-13 17:33:49
问题 I have an array anomalies_ind that was created in this way: data_path = r"C:\Users\matth\Downloads\TRMM_3B42RT\3B42RT_Daily.201001.7.nc4" f = Dataset(data_path) latbounds = [ -45 , -10 ] lonbounds = [ 105, 160 ] lats = f.variables['lat'][:] lons = f.variables['lon'][:] # latitude lower and upper index latli = np.argmin( np.abs( lats - latbounds[0] ) ) latui = np.argmin( np.abs( lats - latbounds[1] ) ) # longitude lower and upper index lonli = np.argmin( np.abs( lons - lonbounds[0] ) ) lonui =

Basemap and density plots

妖精的绣舞 提交于 2019-12-13 11:54:14
问题 I would like to create a density plot using basemap. The data I have is ungridded and repeating or very close to each other. I've tried gridding the data and then plotting the number of bins using pcolor but I keep getting a buffer size error even though all the datasets have equal length. My original idea was to use the basemap script below but I can only get scatter to work, though this does not give me a density plot. m = Basemap(resolution='f',projection='merc', lon_0=160, llcrnrlat=-30.0

Program runs forever without giving an error when plotting data only on continent [closed]

别说谁变了你拦得住时间么 提交于 2019-12-13 10:26:47
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I was trying to plot data only on continent. I asked a question about this before and I've got the answer here. Now when I implemented it in the code, the program will run without giving an error. However, it

How to make smooth circles on basemap projections in Matplotlib by Python

只谈情不闲聊 提交于 2019-12-13 03:58:29
问题 I'm not advanced user of Python, but due to my scientific work I got tasks to plot some graphs with Matplotlib. Now I have to draw smooth-deformed according to the basemap projection, circles around given point. But in the result I got circles with broken lines: import numpy as np import matplotlib.pyplot as plt def plot_mwd(RA,Dec,org=0,title='GCS', projection='aitoff'): x = np.remainder(RA+360-org,360) # shift RA values ind = x>180 x[ind] -=360 # scale conversion to [-180, 180] x=-x #

How to plot interpolate station data over a map (basemap)?

旧时模样 提交于 2019-12-13 03:56:49
问题 I've got a file with accumulated rainfall over a month in 5 stations. There are lat, lon and rain data in csv file. My file is just like that: Out[18]: lat lon rain 0 -48.379000 -1.067000 213.0 1 -48.435548 -1.401513 157.2 2 -48.482217 -1.449707 147.0 3 -48.457779 -1.249272 182.6 4 -48.479847 -1.308735 49.4 I'm trying to do: import numpy as np import pandas as pd from matplotlib.mlab import griddata from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt from matplotlib

python - Display heat map on a Matplotlib/Basemap

旧巷老猫 提交于 2019-12-13 03:46:34
问题 I have a dataset of longitudes/latitudes as follows: id,spp,lon,lat 1a,sp1,1,9 1b,sp1,3,11 1c,sp1,6,12 2a,sp2,1,9 2b,sp2,1,10 2c,sp2,3,10 2d,sp2,4,11 2e,sp2,5,12 2f,sp2,6,12 3a,sp3,4,13 3b,sp3,5,11 3c,sp3,8,8 4a,sp4,4,12 4b,sp4,6,11 4c,sp4,7,8 5a,sp5,8,8 5b,sp5,7,6 5c,sp5,8,2 6a,sp6,8,8 6b,sp6,7,5 6c,sp6,8,3 I want to display a heat map representing the density of points over a geographical map using Matplotlib/Basemap, using the code below (more or less based on this one): from mpl_toolkits

Half of the world masked when using maskoceans in Basemap

你。 提交于 2019-12-12 12:17:27
问题 I would like to mask oceans when plotting the data from a netCDF dataset. I followed the great instructions given in the answer to this question. It works great for half of the world, but somehow, everything west of Greenwich is masked as well, both ocean and land. Here is my code: import netCDF4 import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.cm as cm import mpl_toolkits from mpl_toolkits import basemap from mpl_toolkits.basemap import Basemap,

Plotting curved line in Python Basemap

陌路散爱 提交于 2019-12-12 09:43:03
问题 I would like to plot curved/arced lines on a Basemap map. I can plot a straight line using map.plot(x,y,..), but how do I make it curved/have arrows? In matplotlib, this can be done using annotate(..), but Basemap doesn't have this method. Any ideas? 回答1: This is a very old question, but I thought it might be good to answer anyway. When you said curved lines, I assumed you meant drawing a great circle. There is an example of doing exactly that in the basemap documentation, which I have

Force use of scientific style for basemap colorbar labels

大憨熊 提交于 2019-12-12 08:11:55
问题 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',

overlaying a basemap on contours

谁说胖子不能爱 提交于 2019-12-11 10:46:29
问题 This question is a follow-up to an earlier question and from @JoeKington here. Both of these solutions work excellently for my needs. However I have been trying to overlay a basemap on the contours. Going by the example here http://matplotlib.org/basemap/users/examples.html, I do not seem to get it right. I think my basic problem is to convert the contour x,y values into map coordinates. I reproduce below the codes for 1) contours (as given by @usethedeathstar, which works very well) and 2)