Print variable value in plot title with custom precision after decimal point (Plots.jl)

Hi all!
I’m trying to print variable values in the title of a plot using:

title = L"\eta_1 = %$(mean(df_b.η))"

But the result shows many numbers after the decimal point which takes the whole line of the title. How can I control the format of the print?

Thank you!

You can probably do

title = L"\eta_1 = %$(round(mean(df_b.η); digits = 2))"

And change 2 to your preferred precision

This helps only a little, the number that shows is:
after using your suggestion the display is now:

Which helps, but what I need the display to be in the form of:

Sorry I only thought about small numbers. For the specific case you could use the sigdigits kwarg of round.

There might even be a way with round to do something accurate in both case but I am not at a computer with Julia now.

Another alternative is to use Printf · The Julia Language

sigdigits works! thank you!!!