matplotlib-basemap

Basemap and Matplotlib - Improving Speed

馋奶兔 提交于 2020-01-01 12:32:09
问题 I'm creating a tool for geospatial visualization of economic data using Matplotlib and Basemap . However, right now, the only way I thought of that gives me enough flexibility is to create a new basemap every time I want to change the data. Here are the relevant parts of the code I'm using: class WorldMapCanvas(FigureCanvas): def __init__(self,data,country_data): self.text_objects = {} self.figure = Figure() self.canvas = FigureCanvas(self.figure) self.axes = self.figure.add_subplot(111) self

Basemap and Matplotlib - Improving Speed

℡╲_俬逩灬. 提交于 2020-01-01 12:32:08
问题 I'm creating a tool for geospatial visualization of economic data using Matplotlib and Basemap . However, right now, the only way I thought of that gives me enough flexibility is to create a new basemap every time I want to change the data. Here are the relevant parts of the code I'm using: class WorldMapCanvas(FigureCanvas): def __init__(self,data,country_data): self.text_objects = {} self.figure = Figure() self.canvas = FigureCanvas(self.figure) self.axes = self.figure.add_subplot(111) self

plot gebco data in python basemap

拈花ヽ惹草 提交于 2019-12-30 05:28:03
问题 I have downloaded some gebco bathymetry data as a netCDF file. I would like to plot it with python-basemap. I have tried, import netCDF4 from mpl_toolkits.basemap import Basemap # Load data dataset = netCDF4.Dataset('/home/david/Desktop/GEBCO/gebco_08_-30_45_5_65.nc') # Extract variables x = dataset.variables['x_range'] y = dataset.variables['y_range'] spacing = dataset.variables['spacing'] # Data limits nx = (x[-1]-x[0])/spacing[0] # num pts in x-dir ny = (y[-1]-y[0])/spacing[1] # num pts in

Filling shapefile polygons with a color in matplotlib

陌路散爱 提交于 2019-12-29 07:59:23
问题 I am searching way to fill polygons of a shapefile based on a value. So far from basemap tutorial (http://basemaptutorial.readthedocs.io/en/latest/shapefile.html) i 've found how to fill the polygons with a specific color. import matplotlib.pyplot as plt import pypyodbc from mpl_toolkits.basemap import Basemap from matplotlib.patches import Polygon from matplotlib.collections import PatchCollection from matplotlib.patches import PathPatch import numpy as np fig= plt.figure() ax= fig.add

Matplotlib Basemap animation

穿精又带淫゛_ 提交于 2019-12-29 07:16:08
问题 I'm using basemap to plot some points on a map, and I want to add any kind of animation to it. It could literally serve no purpose at all, as long as it is an animation it would be nice. This is what I currently have to make the map, from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np import matplotlib.animation as animation map = Basemap(projection='robin', resolution = 'l', area_thresh = 1000.0, lat_0=0, lon_0=-130) map.drawcoastlines() map

Matplotlib basemap: Popup box

不想你离开。 提交于 2019-12-28 05:42:27
问题 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? 回答1: Yes it is possible thanks to matplotlib's event handling framework. I couldn't find an already written example which does what you are particularly interested in so I wrote one (which I will put forward for inclusion in the matplotlib source). I would read http://matplotlib.sourceforge.net/users/event_handling.html thoroughly to best

matplotlib mouseclick event in pie chart

痴心易碎 提交于 2019-12-25 03:00:31
问题 Is there a way in matplotlib and Python to return the value/label clicked in a pie chart. For example if user clicks on sliver A of pie chart, return value A. If user clicks on sliver B of B pie chart, return value B. 回答1: from matplotlib import pyplot as plt # make a square figure and axes plt.figure(figsize=(6,6)) ax = plt.axes([0.1, 0.1, 0.8, 0.8]) labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' fracs = [15,30,45, 10] explode=(0, 0.05, 0, 0) p = plt.pie(fracs, explode=explode, labels=labels,

Python quiver and pcolormesh not lining up exactly right

柔情痞子 提交于 2019-12-24 11:29:57
问题 I am trying to overlay a quiver plot of wind field on a map with a pcolormesh of the windspeed. from mpl_toolkits.basemap import Basemap from pylab import * lonMin = 115.5 lonMax = 124.5 latMin = 10 latMax = 20 res = 0.25 lonGrid = arange(lonMin, lonMax, res) latGrid = arange(latMin, latMax, res) lonGrid,latGrid = meshgrid(lonGrid,latGrid) u = random(lonGrid.shape) v = random(lonGrid.shape) m = Basemap(llcrnrlon=lonMin,llcrnrlat=latMin,urcrnrlon=lonMax,urcrnrlat=latMax, resolution = 'i') m

what's wrong with basemap projection=“cyl”?

家住魔仙堡 提交于 2019-12-24 09:25:46
问题 In recent days, I have visualized my ncep reanalysis data using Basemap. It is found that only half data appears when using Basemap(projection="cyl",lon_0=0.0,lat_0=0.0, resolution="c") , but the whole data occurs when using Basemap(projection="cyl",lon_0=180.0,lat_0=0.0, resolution="c") . Furthermore, I changes the projection, but still set the central longitude to 0 degree like Basemap(projection="hammer",lon_0=0.0,lat_0=0.0, resolution="c"), but the whole data. The whole data occurs. what

How to specify colorbar range and keep it regardless of plotting values

你。 提交于 2019-12-24 08:56:41
问题 I typed this up last night then as I was about to submit it I figured it out. Submitting in case anyone else needs it. I am plotting meteorological values for every hour for multiple days on basemap. I want to keep the same values of the colorbar at all times for each map. Lets say from 0-10 for each plot. Sometimes the values are all very close to zero and others they range from 0-10. for file in files: ncfile = Dataset(file) cbarticks=np.arange(0.0,10.0,0.5) bm.contour(x, y, to_np