Colorbar rendering issue with mpld3 vs pyplot

32 Views Asked by At

I have an issue when rendering a figure with a colorbar with mpld3 but it works fine with pyplot. This is how it is supposed to look like (figure rendered with plt.show()):

figure rendered with plt.show()

when using mpld3.show() to display the plot I get the colorbar looking like this:

figure rendered with mpld3.show()

notice that:

  • the colors are inverted (when compared to the correct plot)

  • it starts at 10ˆ-7 instead of 10^-6

  • it is shifted to the side (down and to the right)

This is the piece of code I am using, only uncommenting plt.show() to mpld3.show() and vice versa:

    fig, ax = plt.subplots()
    pcm = ax.pcolormesh(X, Y, summed_data, cmap=custom_cmap, norm=norm)
    fig.colorbar(pcm, location='left')
    ax.set_xlabel(x_name + ' [cm]')
    ax.set_ylabel(y_name + ' [cm]')
    ax.set_title('Plot title')

I am not showing how X, Y, cmap and norm are defined because I don't think the problem is there, but I don't mind adding it.

0

There are 0 best solutions below