2

In the following example (modified from here) I get an error regarding the use of the extended keyword when using a log scale:

import matplotlib.pyplot as plt
import numpy as np
from numpy import ma
from matplotlib import colors, ticker, cm
from matplotlib.mlab import bivariate_normal
N = 100
x = np.linspace(-3.0, 3.0, N)
y = np.linspace(-2.0, 2.0, N)
X, Y = np.meshgrid(x, y)
z = (bivariate_normal(X, Y, 0.1, 0.2, 1.0, 1.0)
     + 0.1 * bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0))
cs = plt.contourf(X, Y, z, locator=ticker.LogLocator(), cmap=cm.PuBu_r, extend='both')
cbar = plt.colorbar()
plt.show()

I have tried this in versions 1.5.3 and 1.5.1 and the exact error is

ValueError: extend kwarg does not work yet with log scale

This is even said in that page so this is no surprise.

I have tried some workarounds to that, such as cs.cmap.colorbar_extend = True, but, although I get no error, the extended option isn't implemented.

Is there a workaround for this? In other words: can I implement a log scale on contourf even though the keyword isn't implemented yet?

Thank you.

TomCho
  • 3,204
  • 6
  • 32
  • 83
  • 1
    When running your code I get a `ValueError: extend kwarg does not work yet with log scale`, which is pretty self-explanatory. So you cannot use `extend` on a log scale. Is the question how to implement the `extend` keyword even though it is not implemented? – ImportanceOfBeingErnest Dec 06 '16 at 08:28
  • @ImportanceOfBeingErnest Yes, that is what I meant. Was that not clear? I'll try to make it clearer. – TomCho Dec 06 '16 at 20:58
  • @ImportanceOfBeingErnest Edited, sorry it wasn't clear – TomCho Dec 06 '16 at 21:01

0 Answers0