From: Eric Firing <efiring@ha...>  20120613 18:33:38

On 06/13/2012 07:31 AM, jonasr wrote: > > Hi, > > im actually trying to make a countour plot Z=f(X,Y) from two variables X,Y . > My Problem is that i have to use a logarithmic scale for the Z values. > If i plot the data with the logarithmic scale it gets pretty ugly, because i > have a lot of values which are zero, > which means on the log scale the value goes to inf. > Here is an example what i mean > > http://www.imagebanana.com/view/qh1khpxp/example.png > > I acutally have no idea how to make the plot look better, > maybe somebody has an idea ? Use np.ma.masked_less to mask out values below some threshold before taking the log. e.g., import matplotlib.pyplot as plt import numpy as np x = np.arange(0, 1, 0.01) y = np.arange(0, 8, 0.05) X, Y = np.meshgrid(x, y) Z = 10 ** (5 + 11 * X * np.sin(Y)) Z = np.ma.masked_less(Z, 1e4) Zlog = np.ma.log10(Z) CS = plt.contourf(X, Y, Zlog, levels=np.arange(3, 5.01, 1.0), extend='both') plt.colorbar() Eric > > thank you 