From h51.yang at hdr.qut.edu.au Sat Feb 26 06:30:55 2022 From: h51.yang at hdr.qut.edu.au (Haoyu Yang) Date: Sat, 26 Feb 2022 11:30:55 +0000 Subject: [Matplotlib-users] Report a possible colorbar extend bug Message-ID: 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). [cid:image002.png at 01D82B54.CD991AC0][cid:image003.png at 01D82B54.CD991AC0][cid:image005.png at 01D82B54.D51B8F30] 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.png Type: image/png Size: 110408 bytes Desc: image002.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image003.png Type: image/png Size: 108221 bytes Desc: image003.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image005.png Type: image/png Size: 130972 bytes Desc: image005.png URL: