-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Contourf Colorbar #5055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've already worked a little bit on creating a fix for this here. The issue seems to be related to trying to handle creation of This fix above gives the colorbar I want: |
That color bar does look "correct". You asked attn @efiring |
If you do import matplotlib.pyplot as plt
import numpy as np
import matplotlib.colors as mplc
x, y = np.mgrid[0:1:0.01, 0:1:0.01]
r = np.sqrt(x ** 2 + y ** 2)
z = np.sin(6 * np.pi * r)
norm = mplc.Normalize(0, 0.5)
fig0, ax0 = plt.subplots(1, 1, )
cf0 = ax0.contourf(x, y, z, np.arange(0, .5, .01), norm=norm,
extend='both', cmap='viridis')
cbar0 = plt.colorbar(cf0,) which is what I think your intent was. |
Got it. I was unaware of the |
I could have sworn there was a This is something where there are multiple places where it might make sense to be able to control it, we may not always be consistent on where it should be controlled, there is a high degree of 'do the right thing' required, and we can't break back compatibility. I am only aware of the Where would you have looked in the docs to try and find out this sort of stuff? |
Looking more closely I see that it's in the |
I am indifferent to creating on SO post on this. |
Does the problem still happen if you remove the comma in the colorbar()
call?
Also, next time, please file a new issue rather than resurrecting an old
issue, unless the problem is identical.
…On Dec 26, 2016 3:54 AM, "Ankit Barik" ***@***.***> wrote:
The 'extend' keyword gives a line instead of a colorbar.
Matplotlib version: 2.0.0rc2+2827.gab98852
Numpy version: 1.13.0.dev0+2498b74
Compiler: gcc
Here's the same piece of code generating the following
`import matplotlib.pyplot as plt
import numpy as np
import matplotlib.colors as mplc
x, y = np.mgrid[0:1:0.01, 0:1:0.01]
r = np.sqrt(x ** 2 + y ** 2)
z = np.sin(6 * np.pi * r)
norm = mplc.Normalize(0, 0.5)
fig0, ax0 = plt.subplots(1, 1, )
cf0 = ax0.contourf(x, y, z, np.arange(0, .5, .01), norm=norm,
extend='both', cmap='viridis')
cbar0 = plt.colorbar(cf0,)`
[image: figure_1]
<https://cloud.githubusercontent.com/assets/13730345/21478977/36db3784-cb51-11e6-9ee3-446fd3e19e9a.png>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#5055 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-BXatTQ8xPtfZxbO7xfV63hyZO3Aks5rL4DigaJpZM4F8eOy>
.
|
The comment above refers to what has now been opened as #7686. |
The
contourf
colorbar
doesn't work as expected.The following code:
Produces the following figure:
Compare this with the colorbar of, e.g. a
pcolormesh
:That's a nice colorbar, and it's what I expect the default behavior to be for
contourf
also. Is there a reason thecontourf
colorbar behaves this way? I've looked at using thevmin
,vmax
args, and the result is the same. Also, the result is the same fortricontourf
colorbars as well.The text was updated successfully, but these errors were encountered: