1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Position of colorbar position with "extend" parameter

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to do a plot with the extend='max' option of contourf. However the the colorbar is forced to the right-side bottom of the plot with this oprion. The colorbar is centered (as it should be) when the extend option is not used.

    Plot with extend='max' option:

    [​IMG]

    Plot with no extend option:

    [​IMG]

    Relevant code snippet:

    contour = ax.contourf(x, y, val, cmap='gist_yarg', extend='max',
    levels=np.linspace(0, 0.1, 200))

    cbar = plt.colorbar(contour, fraction=0.05, pad=0.03, format='%.2f')


    How can I ensure that the colorbar remains centered ? Thanks.

    Continue reading...

Compartilhe esta Página