Scientific Notation in Plots.jl colorbar


edit: working example

using Plots
x = rand(10,10) / 1e6


I don’t like how the colorbar’s labels are cut off by the plot edge. Is there a way to tell the plotting package to use scientific notation for the colorbar contour labels? I know there’s xformatter/yformatter=:scientific but I can’t find anything for the colorbar.

The best that I got was using Plotly and some margin adjustments:

using Plots; plotly()
x = rand(10,10) / 1e6
    left_margin =,
    right_margin =,
    top_margin =,
    bottom_margin =,
    colorbar_title = "Text Color Bar",

Captura de tela de 2021-03-23 14-41-54

1 Like

I don’t mind using plotly, but I really don’t like the nano/mico suffix on the colorbar and would still prefer scientific notation. Do you know if this is possible with Plotly?

I guess what I’m looking for is something similar to the output of similar code in Python/matplotlib.

However, when I plot via the pyplot() backend of Plots.jl, this does not happen

edit:new user restrictions removed so I embedded the second image instead of providing it via link

The Plots.jl library is altering the Matplotlib theme and I don’t know where to look to remove this customization.

With PyPlot I got your result.

using PyPlot
x = rand(10,10) / 1e6
1 Like

Hmm yeah I get the same thing when calling PyPlot directly instead of using Plots.jl, so it seems like the Plots.jl wrapper is customizing the plot environment in some way. If I figure out anything further I’ll be sure to update here.


I asked in the Slack I learned that @isentropic (sorry if not the same isentropic) is working on this kind of enhancements here:

That PR has had a lot of activity recently so it seems like something good could come out soon!


This has been merged and already live in Plots#master with pyplot backend

1 Like


Perhaps it’s too late to give another solution, but I post it here as an alternative. With PlotlyJS.jl you can customize better the plot appearance. In your case setting colorbar_exponentformat =“power” or colorbar_exponentformat=“e” you get what you’d like to be displayed as ticklabels:

using PlotlyJS
z = rand(10,10) / 1e6
trace=contour(z=z', colorbar_thickness=23, 
pl=plot(trace, Layout(width=400, height=350))



Note that the transpose, z’, is necessary instead z, because of the major order used by plotly.js to serialize the arrays.