Plots.jl: changing the overall font size

Created on 2 Nov 2016  Â·  18Comments  Â·  Source: JuliaPlots/Plots.jl

how can I increase the overall font size? I need many plots for a presentation and the font is just too small to be legible.
Is there a less clumsy way than manually defining all possible fonts than how I do it in this example

using Plots; pyplot()
font = Plots.font("Helvetica", 18)
myfonts = Dict(:guidefont=>font, :xtickfont=>font, :ytickfont=>font, :legendfont=>font)
...
plot(data; myfonts...)
pdf("first")
...
scatter(other_data; myfonts...)
pdf("second")

Suppose I like the relative size of an axis label and a tick label, so I don't want to have to play around how to keep their relative font size constant. This is similar but not identical to #482

Most helpful comment

I was just about to write out how easy this would be, and decided it would be quicker to just implement. Give me a few minutes and this should work:

using Plots
Plots.scalefontsizes(2)
plot(rand(10), title="hello", guide="guide")

All 18 comments

You can set the defaults once at the beginning. You can also add custom
settings to your juliarc.jl file.

On Wednesday, November 2, 2016, Frederik Beaujean [email protected]
wrote:

how can I increase the overall font size? I need many plots for a
presentation and the font is just too small to be legible.
Is there a less clumsy way than manually defining all possible fonts than
how I do it in this example

using Plots; pyplot()
font = Plots.font("Helvetica", 18)
myfonts = Dict(:guidefont=>font, :xtickfont=>font, :ytickfont=>font, :legendfont=>font)...plot(data; myfonts...)pdf("first")...scatter(other_data; myfonts...)pdf("second")

Suppose I like the relative size of an axis label and a tick label, so I
don't want to have to play around how to keep their relative font size
constant. This is similar but not identical to #482
https://github.com/tbreloff/Plots.jl/issues/482

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/tbreloff/Plots.jl/issues/560, or mute the thread
https://github.com/notifications/unsubscribe-auth/AA492jxtKxZV0_pFI9jBEtdr2TqD9VCFks5q6F77gaJpZM4KnDII
.

You can set the defaults once at the beginning. You can also add custom settings to your juliarc.jl file.

How do I do that? Can you provide example code, please?

using Plots;  pyplot(title = "every plot has this title")

From https://juliaplots.github.io/basics/:

Tip: You can see the default value for a given argument with default(arg::Symbol), and set the default value with default(arg::Symbol, value) or default(; kw...). For example set the default window size and whether we should show a legend with default(size=(600,400), leg=false).

From https://juliaplots.github.io/install/:

Choose a backend, and optionally override default settings at the same time:
pyplot(size = (300,300), legend = false)

Tip: You can override standard default values in your ~/.juliarc.jl file: PLOTS_DEFAULTS = Dict(:markersize => 10, :legend => false)

You should really take the time to look through the docs. I took the time to make them...

edit: sorry I missed that in the docs, I did take the time to look at them over and over again. I have to write manuals myself so I know very well what you mean.

Ok, so to be explicit I have to do

font = Plots.font("Helvetica", 18)
pyplot(guidefont=font, xtickfont=font, ytickfont=font, legendfont=font)

but there is no support for just upscaling the font while keeping the relative size of tick to legend font constant?

I was just about to write out how easy this would be, and decided it would be quicker to just implement. Give me a few minutes and this should work:

using Plots
Plots.scalefontsizes(2)
plot(rand(10), title="hello", guide="guide")

tmp

Awesome, thank you very much for the immediate fix! works well. Plots.jl has a great promise, as an experienced matplotlib user, I appreciate how you made a lot of things much easier. Keep up the good work!

@tbreloff Should scalefontsizes perhaps be exported?

Makes sense. @floswald , maybe you can add the export to your PR?

yes sure. sorry guys now I actually did forget about this PR. can't finish before thursday morning, bear with me.

Yet regarding this issue, is there any way to scale things up in a way that I can rerun the code multiple times without getting the font bigger and bigger? Something like a global font size. The idea of scaling is perfect except that it assumes a single run of the cell, which is never the case when we are working on the plot.

@floswald FWIW, it looks like scalefontsizes and resetfontsizes still haven't been exported.

Unfortunately scalefontsizes doesn't seem to work with pgfplots backend.

Since GR has become the default backend I had no more use for this function
because stuff looks great with default settings on my screen.

I would have thought that pgfplots takes the font sizes from the
surrounding Tex document? At least that was my impression.

On Wed 21 Feb 2018 at 22:32, Carsten Bauer notifications@github.com wrote:

Unfortunately scalefontsizes doesn't seem to work with pgfplots backend.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/JuliaPlots/Plots.jl/issues/560#issuecomment-367479970,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA-Wds1A0mX1dUx06AJTC5XQgXFNfwjmks5tXIt4gaJpZM4KnDII
.

How do I increase fontsize only for legend (in the above case y1)

Appreciate any help.

Thanks.

legendfontsize

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dancsi picture dancsi  Â·  4Comments

Cody-G picture Cody-G  Â·  3Comments

asinghvi17 picture asinghvi17  Â·  3Comments

jebej picture jebej  Â·  4Comments

lstagner picture lstagner  Â·  5Comments