logo

How to Control Number Notation When Plotting in Julia 📂Julia

How to Control Number Notation When Plotting in Julia

Code

formatter option supports :auto, :plain, and :scientific.

  • :auto: automatically selects the appropriate format; if an entry becomes too long it will switch to scientific notation.
  • :plain: displays the value in decimal notation as-is.
  • :scientific: shows only the leading significant digits as the mantissa and expresses the magnitude as a power of ten.
using Plots

plot(1e+10rand(100), title = "plain", yformatter = :plain, legend = :none)
plot(1e+10rand(100), title = "scientific", yformatter = :scientific, legend = :none)

alt text alt text

One regrettable point is that this is precisely an area where Julia still cannot match MATLAB. In practice—e.g., when preparing papers—scientific notation is often used and one frequently needs to control its style, yet the flexibility for doing so is currently too limited.

Environment

  • OS: Windows
  • Julia: v1.12.0