You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When plotting with imshow an array with all one value.
a = ones((10,10))
imshow(a)
colorbar()
show()
colorbar.py:829: RuntimeWarning: invalid value encountered in divide
z = np.take(y, i0) + (xn - np.take(b, i0)) * dy / db
The output is thus:
I realize this is a corner case, but it would be very useful for the colorbar auto scale to somehow indicate the value.
Putting this code into colorbar.py
_locate function
immediately before the return(z) call
if np.isnan(z).any():$
z = np.array(range(1,len(x)))/float(len(x))$
remedies the problem for me.
I can send a patch file for fork, if anyone is interested.
I presume this is not the best way to remedy the issue for matplotlib proper, probably better to detect the condition earlier and deal with it, then screen for nan's
The text was updated successfully, but these errors were encountered:
The correct place to fix this is where vmax and vmin are calculated and expand them if they are equal. I could have sworn we already fixed this...There may be an un-merged PR floating around that addresses this.
I'm rather new to this site, but did this issue ever get resolved? I'm trying to use colorbar on arrays with the same value over most positions. I'm getting the error message discussed above and tried the
if np.isnan(z).any():$
z = np.array(range(1,len(x)))/float(len(x))$
tip, but still have an error message. Any help with this would be great.
When plotting with imshow an array with all one value.
colorbar.py:829: RuntimeWarning: invalid value encountered in divide
z = np.take(y, i0) + (xn - np.take(b, i0)) * dy / db
The output is thus:
I realize this is a corner case, but it would be very useful for the colorbar auto scale to somehow indicate the value.
Putting this code into colorbar.py
_locate function
immediately before the return(z) call
remedies the problem for me.
I can send a patch file for fork, if anyone is interested.
I presume this is not the best way to remedy the issue for matplotlib proper, probably better to detect the condition earlier and deal with it, then screen for nan's
The text was updated successfully, but these errors were encountered: