[Matplotlib-users] Report a possible colorbar extend bug
Thomas Caswell
tcaswell at gmail.com
Wed Mar 9 20:35:40 EST 2022
Haoyu,
Please subscribe to the mailing list to post unmoderated.
This looks like a real bug to me, please report this as an issue on github (
https://github.com/matplotlib/matplotlib/issues/new/choose)?
Tom
On Wed, Mar 9, 2022 at 6:59 PM Haoyu Yang <h51.yang at hdr.qut.edu.au> wrote:
> Dear Matplotlib team,
>
>
>
> I hope this letter finds you well.
>
>
>
> I’m a new matplotlib so I’m not sure if it’s me doing wrong or there could
> be a bug replated to matplotlib itself. I’m currently running Python 3.10
> with Matplotlib 3.5.1. This possible bug seems to be related to some
> incompatibility between the “extend” argument in “plt.figure.colorbar” and
> “.ax.invert_yaxis()” functions. More specifically, if I just extend the max
> of colorbar (first figure) or just invert the y-axis of the colorbar(second
> figure), everything work fine. However, if I do this two at the same time,
> the colorbar would be inverted while the extended arrow is not(figure
> three).
>
>
>
>
>
>
>
> And I here enclosed the code which I use to create the plot:
>
> # Generate X/Y point mesh grid
>
> x = np.linspace(-4.5, 1.5, 400)
>
> y = np.linspace(-8, -2, 400)
>
> X, Y = np.meshgrid(x, y)
>
> potential, rate_determining_step =
> calculate_limiting_potential_from_linear_relations(X, Y,
> free_energy_dict)[0], calculate_limiting_potential_from_linear_relations(X,
> Y, free_energy_dict)[1] # calculate limiting potential for each point on
> the mesh grid
>
>
>
> # Create backup ground volcano plot
>
> fig = plt.figure(figsize=[8, 6])
>
> background = fig.add_subplot(111) # add sub plot
>
>
>
> # Add contour plot
>
> contour = background.contourf(X, Y, potential, levels=512,
> cmap="rainbow") # create filled contour (reverse rainbow)
>
>
>
> # Create colorbar
>
> cbar = fig.colorbar(contour, shrink=0.95, aspect=15, ticks=[1, 2, 3,
> 4]) # create colorbar (shrink/aspect for the size of the bar)
>
> cbar.set_label("Limiting Potential (eV)", fontsize=16) # add label to
> the colorbar
>
> cbar.ax.tick_params(labelsize=12) # set tick label size
>
> cbar.ax.invert_yaxis() # put the colorbar upside down
>
>
>
> Sorry I can’t send you the script and datasheet because it contents
> sensitive data. Thanks for your time and wishing you all the best.
>
>
>
> Regards,
>
> Haoyu
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
--
Thomas Caswell
tcaswell at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/matplotlib-users/attachments/20220309/5f162fe0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 110408 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/matplotlib-users/attachments/20220309/5f162fe0/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 108221 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/matplotlib-users/attachments/20220309/5f162fe0/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 130972 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/matplotlib-users/attachments/20220309/5f162fe0/attachment-0005.png>
More information about the Matplotlib-users
mailing list