why does my colorbar have lines in it?

In case you create vector graphics, have you tried this (taken from http://matplotlib.org/api/pyplot_api.html?highlight=colorbar#matplotlib.pyplot.colorbar): “It is known that some vector graphics viewer (svg and pdf) renders white gaps between segments of the colorbar. This is due to bugs in the viewers not matplotlib. As a workaround the colorbar can be rendered with overlapping segments: cbar = … Read more

draw grid lines over an image in matplotlib

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 do what you ask for: import matplotlib.pyplot as plt import matplotlib.ticker as plticker try: from PIL import Image except ImportError: import … Read more

Fill countries in python basemap

As has already been said by @unutbu, Thomas’ post here is exactly what you are after. Should you want to do this with Cartopy, the corresponding code (in v0.7) can be adapted from http://scitools.org.uk/cartopy/docs/latest/tutorials/using_the_shapereader.html slightly: import cartopy.crs as ccrs import matplotlib.pyplot as plt import cartopy.io.shapereader as shpreader import itertools import numpy as np shapename=”admin_0_countries” countries_shp … Read more

Plot only on continent in matplotlib

There’s method in matplotlib.basemap: is_land(xpt, ypt) It returns True if the given x,y point (in projection coordinates) is over land, False otherwise. The definition of land is based upon the GSHHS coastline polygons associated with the class instance. Points over lakes inside land regions are not counted as land points. For more information, see here.