matplotlib-basemap

matplotlib: preventing a few very large (or small) values to affect my contour

蹲街弑〆低调 提交于 2019-12-06 14:02:09
in plotting the data some times there are a few very large (or very small) numbers which, if not taken care of, will affect the contour in a bad way. a solution is to take out the 10% highest and lowest data out of the contour color grading and considering them as less than and more than. the following figure shows the idea: the two arrow shapes on the top and the bottom of the bar support this idea. any value above 14 will be shown in white and any value below -2 will be shown in black color. how is it possible in matplotlib? How can I define: - to put the 5% of highest values and 5% of

Pop up annotations on matplotlib within wxPython

南楼画角 提交于 2019-12-06 13:49:08
问题 I have a two panel wxPython GUI set up. In my right panel, I have a map display using Basemap. On this basemap (of the United States) I plot a scatter plot of different cities. I would like to be able to click on these dots and have a pop up window within my GUI that gives some information relative to that dot I select (ex. City, lat/long, etc. -- I would have all this info stored in a list or other means). I have come across AnnoteFinder, but this does not seem to work inside my GUI (it will

How to make grouper and axis the same length?

十年热恋 提交于 2019-12-06 12:48:00
For my assignment I'm supposed to plot the tracks of 20 hurricanes on a map using matplotlib. However when I run my code I get the error: AssertionError:Grouper and axis must be the same length Here's the code I have: import numpy as np from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt from PIL import * fig = plt.figure(figsize=(12,12)) ax = fig.add_axes([0.1,0.1,0.8,0.8]) m = Basemap(llcrnrlon=-100.,llcrnrlat=0.,urcrnrlon=-20.,urcrnrlat=57., projection='lcc',lat_1=20.,lat_2=40.,lon_0=-60., resolution ='l',area_thresh=1000.) m.bluemarble() m.drawcoastlines(linewidth=0.5)

basemap ImportError: No module named 'mpl_toolkits.basemap'

帅比萌擦擦* 提交于 2019-12-06 09:23:43
问题 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? 回答1: 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

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

梦想与她 提交于 2019-12-06 06:30:07
问题 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

Shade states of a country according to dictionary values with Basemap

試著忘記壹切 提交于 2019-12-06 05:49:41
I want to plot the map of Mexico and shade the states accordingly to a the values of a dictionary. I used the following code suggested in previous question ( Easiest way to plot data on country map with python ), so far it plots the country and states, but when I try to define the shading I get an error. Below the code: import numpy as np import matplotlib.pyplot as plt from matplotlib.collections import PatchCollection from mpl_toolkits.basemap import Basemap %matplotlib inline from shapely.geometry import Polygon mexican_states_people = {'AGS': 20,'BC': 57, 'BCS': 562, 'CAMP': 594,'CHIH':

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

筅森魡賤 提交于 2019-12-06 05:31:26
问题 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(

Find a easier way to cluster 2-d scatter data into grid array data

大憨熊 提交于 2019-12-06 05:06:40
I have figured out a method to cluster disperse point data into structured 2-d array(like rasterize function ). And I hope there are some better ways to achieve that target. My work 1. Intro 1000 point data has there dimensions of properties (lon, lat, emission) whicn represent one factory located at (x,y) emit certain amount of CO2 into atmosphere grid network : predefine the 2-d array in the shape of 20x20 http://i4.tietuku.com/02fbaf32d2f09fff.png The code reproduced here: #### define the map area xc1,xc2,yc1,yc2 = 113.49805889531724,115.5030664238035,37.39995194888143,38.789235929357105

Python Interpolation with matplotlib/basemap

谁都会走 提交于 2019-12-06 04:51:07
问题 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

Basemap on the face of a matplotlib.mplot3d cube

ぃ、小莉子 提交于 2019-12-06 03:55:49
As the title suggests, I'm trying to plot a Basemap map on the z=0 surface of a matplotlib.mplot3d lineplot. I know the Axes3D object is capable of plotting on the z=0 surface (via Axes3D.plot, Axes3D.scatter, etc.), but I can't figure out how to do so with a Basemap object. Hopefully the code below shows what I need clearly enough. Any ideas would be much appreciated! import matplotlib.pyplot as pp from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.basemap import Basemap # make sample data for 3D lineplot z = np.linspace(-2, 2, 100) r = z**2 + 1 x = r * np.sin(theta) y = r * np.cos