matplotlib-basemap

Python real time varying heat map plotting

时间秒杀一切 提交于 2019-12-18 18:10:11
问题 I have a 2D grid 50*50. For each location I have an intensity value(i.e data is like (x,y,intensity) for each of those 50*50 locations). I would like to visualize the data as a heatmap. The twist is that every second the intensity will change(for most of the locations), which means I will need to re-draw the heatmap every second. I am wondering what is the best library/approach to handle this kind of real-time varing heatmap. 回答1: This really depends on how you get your data, but: import

How to install Matplotlib's basemap?

心不动则不痛 提交于 2019-12-18 15:53:13
问题 It is unclear to me how to install Matplotlib's Basemap on Windows. Maybe the question is straightforward, I need some help. I followed this tutorial. As far as I understand, first, GEOS and PROJ4 should be installed, and lastly matplotlib-1.4.3.win-amd64-py2.7.exe should be executed. I get stuck with GEOS. I downloaded source code of geos-3.5.0, "untarred" it, then I go to a Command Prompt, change directory to geos-3.5.0 and run this: export d://test but it does not work. 回答1: Use this

Eliminate white edges in Matplotlib/Basemap pcolor plot

自闭症网瘾萝莉.ら 提交于 2019-12-18 12:59:18
问题 I am plotting data on a map using this code: import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.cm as cm from mpl_toolkits.basemap import Basemap from matplotlib.patches import Polygon from scipy.io import netcdf ncfile = netcdf.netcdf_file(myfile.nc,'r') lon = ncfile.variables['longitude'][:] lat = ncfile.variables['latitude'][:] data = ncfile.variables['mydata'][:] ncfile.close() m = Basemap(projection='nplaea', boundinglat=40, lon_0=270) m

How to use set clipped path for Basemap polygon

喜你入骨 提交于 2019-12-18 12:35:41
问题 I want to use imshow (for example) to display some data inside the boundaries of a country (for the purposes of example I chose the USA) The simple example below illustrates what I want: import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import RegularPolygon data = np.arange(100).reshape(10, 10) fig = plt.figure() ax = fig.add_subplot(111) im = ax.imshow(data) poly = RegularPolygon([ 0.5, 0.5], 6, 0.4, fc='none', ec='k', transform=ax.transAxes) im.set_clip_path(poly)

Python and Matplotlib and Annotations with Mouse Hover

♀尐吖头ヾ 提交于 2019-12-18 12:09:06
问题 I am currently employing this code to have pop up annotatations on a map when i click on a point in a Basemap Matplotlib Plot. dcc = DataCursor(self.figure.gca()) self.figure.canvas.mpl_connect('pick_event',dcc) plot_handle.set_picker(5) self.figure.canvas.draw() class DataCursor(object): import matplotlib.pyplot as plt text_template = 'x: %0.2f\ny: %0.2f' x, y = 0.0, 0.0 xoffset, yoffset = -20 , 20 text_template = 'A: %s\nB: %s\nC: %s' def __init__(self, ax): self.ax = ax self.annotation =

Basemap with Python 3.5 Anaconda on Windows

大憨熊 提交于 2019-12-18 10:20:05
问题 I use Python 3.5 with latest version of Anaconda on Windows (64 bit). I wanted to install Basemap using conda install basemap . Apparently there is a conflict between Python 3 and basemap. After some googling indeed I found that basemap is not supported on Python 3 for Windows users (ex: https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/TjAwi3ilQaU). For obvious reasons I do not want to downgrade to Python 2. What would then be the simplest alternative solution? Is there an

How to insert scale bar in a map in matplotlib

▼魔方 西西 提交于 2019-12-18 03:56:35
问题 Any ideas on how can I insert a scale bar in a map in matplotlib that shows the length scale? something like the one I have attached. Or maybe any ideas on measuring and showing distances automatically (not drawing an arrow and writing the distance manually!)? Thanks :) 回答1: There is a an already existing class for scalebars in matplotlib called AnchoredSizeBar. In the below example AnchoredSizeBar is used to add a scalebar to an image (or map over a 100x100 meter area of randomness). import

draw grid lines over an image in matplotlib

丶灬走出姿态 提交于 2019-12-18 02:41:12
问题 How can I draw regular grid lines over a tiff image? I want to draw regular square grids for each interval (say 100 by 100 pixels) over the image and save that with the drawings. I also need to overlay each grid id as '1','2',...at the middle of each grid box. 回答1: You will need the python imaging library (PIL) installed. (See here https://pypi.python.org/pypi/PIL). See these answers for examples of ways to install PIL: answer 1, answer 2 Right, with that installed, the following code should

scatter plot data does not appear on continents in 'hammer' basemap

依然范特西╮ 提交于 2019-12-17 20:48:06
问题 I am attempting to plot a dataset over the 'hammer' basemap using a scatter plot. However, the data points won't plot on top of the continents. I noticed in the matplotlib example, there is also not data on the continents (I assumed this was due to the nature of the example). I'm wondering if I'm doing something wrong, or if data cannot be plotted on top of the continents using 'hammer' by design. If this is the case, is there an ideal basemap to use to plot scatter plot data over the whole

why does my colorbar have lines in it?

最后都变了- 提交于 2019-12-17 15:46:33
问题 Edit : Since this seems to be a popular post, here's the solution that seems to be working well for me. Thanks @gazzar and @mfra. cbar.solids.set_rasterized(True) cbar.solids.set_edgecolor("face") Does anyone know why my colorbar has what appear to be lines in it? Or rather why is the color transition not smooth? I'm using basemap, obviously, but that shouldn't matter since it's all matplotlib calls under the hood AFAICT. I create the map doing something like grays = plt.cm.get_cmap("Grays")