How to scale the fontsizes using Plots.jl - plot

is there a way to rescale all the fontsizes (legend, tickslabels, axislabels…) at once?
Original question from Filippo Vicentini on Slack.

Individual font sizes can be controlled with the titlefontsize, tickfontsize, legendfontsize, tickfontsize, guidefontsize and legendtitlefontsize attributes, but I get that this can be quite tedious.
There is also the thickness_scaling attribute.
plot(rand(10), thickness_scaling = 0.5)
However, this also affects the line widths.
The third option is to call
Plots.scalefontsizes(α)
to scale all font sizes by a factor α. This changes the global fontsize defaults for all subsequent plots and can be undone with
Plots.scalefontsizes(1 / α)
Answer by Daniel Schwabeneder on Slack.

Related

Change plot window size in Julia notebook

I am using Julia notebook and making plots using basic Plots package.
A plot looks good, except its entire size.
I can change the plot size and font size of labels individually. But it becomes less readable unless I change the font size and line width for every component.
So is there a way to change the size of a plot as a whole? I also hope I can change it by default.
To answer your original question in the title, you can change the size of the Plot Window by specifying the size attribute as you already are in your code. See here: http://docs.juliaplots.org/latest/basics/ for more details.
As pointed out by Rashid, you can use the scalefontsize function to scale the font size. You can also scale the thickness by setting the thickness_scaling attribute, see here for more details: http://docs.juliaplots.org/latest/generated/attributes_plot/
To be clear, there is not currently a unified way to scale a plot in the way you are looking for it right now, it has to be done manually (though it would be great to have this unified scaling). I opened a feature request for this here: https://github.com/JuliaPlots/Plots.jl/issues/3153

Create flexible ggplot2 theme that 1) makes the legend and titles larger, 2) will look good irrespective of the final dimensions

I currently am one of the few R users in my company, which consists predominantly of stata users. One problem I've had with making plots using ggplot2 is that the default (theme_grey()) settings have much smaller axis font and a smaller legend than what is found in stata. Moreover, in presentations I find people have trouble reading the legend and titles from a distance.
I'm aware that ggplot2 has a theming system that allows for relative sizing. What I'd ideally like to do is to create a new default theme that I'd apply to all my plots that would make legends and axis titles larger. Importantly, however, very often the graphs I make have varying dimensions when output to pdf (e.g. 8 inch x 10 inch) or ( 10 inch x 13 inch). Since I'd like to apply this theme globally, I need it to produce good/easy to read output irrespective of the dimensions I specify when outputting to pdf.
I'd really appreciate any suggestions for how to do this/how to approach the problem using ggplot2's theming system.
Thanks!
The theme system can easily scale all the (themed) text, but not in a device sized aware way. The various theme sets, including theme_bw(), have an argument base_size which is the baseline size, in points, of fonts to use for the text. Some text is rendered at that size, and some is rendered at sizes relative to that (for example, axis labels and legend labels are rendered at 80% of the baseline size). So by specifying the base_size argument, you can scale all that text.
However, the base_size is in absolute points, not in a size which is relative to the device size. So the larger the device size, the smaller the text is relative to that.

PaperSize option for Gnuplot in fitting fonts?

I used to set PaperSize in Matlab to control the font size in different axis.
This is better than directly changing the fontsize.
I think this kind of procedure can be working for gnuplot too.
Here some overview of papersize in Matlab.
An unanswered question here in SO about setting fontsize with partisan view how to do it.
So Matlab's command
set(hFig, 'PaperSize',[X Y])
Is there any similar way to control the papersize in Gnuplot as Matlab?
I want to get consistent font sizes in my plots.
You can set the overall image size with the terminals size option like
set terminal pdfcairo size 21cm,29.7cm

Change the font size in a seaborn corrplot

My question is how to change the size of font in seaborn using correlation matrix I don't know why somehow the font is too large for me
if you already have the correlation values in your data, you can use a heatmap and set up the size with "annot_kws", for example here setting it to 8.
sns.heatmap(data, vmin=data.values.min(), vmax=1, square=True,
linewidths=0.1, annot=True, annot_kws={"size":8})
and it would look like this:
Regrettably I don't think that's configurable, but what I would recommend is just to make the figure larger e.g.
f, ax = plt.subplots(figsize=(10, 10))
sns.corrplot(df, ax=ax)
If that's not an option and you're primarily interested in the heatmap (not the numerical values), you could do
sns.corrplot(df, annot=False, sig_stars=False, diag_names=False)
I believe you can use the set method, modify the font scale parameter.
sns.set(font_scale=0.5)
If you're using set_context, then you can add a font scaling parameter along with the size of the plot.
sns.set_context("poster",font_scale=.7)
i did this at this works quite well.
enlarged the fig size to able to read it properly
sns.set(style="white")
f, ax = plt.subplots(figsize=(20, 20))
sns.heatmap(bos.corr(),annot=True,annot_kws={"size":15})

How do I increase the size of the points and the text with just one command in ggplot2?

I am plotting some graphs for a poster and a slideshow. I need bigger points and bigger text. I read about ggplot2's theme_set and theme_update. From what I can tell there are only two preset themes and they differ by the color arrangement of the background. However, I want to make all the text bigger and the plotted points bigger.
I learned how to change the font size.
theme_update(axis.text.x=theme_text(size=30))
But that only changes the axis text. I would have to do the same thing for a bunch of other parameters (axis.text.y, axis.title.x etc). Call me "lazy" but I want a single commands that can increase the base size for all text (and preferably the plotted points too). Is there one or two commands that covers all parameters? Alternatively are there any other set themes?
If you are fine with the colors of either of the two default themes, both take an argument of a base size for text. This is carried over to all the text around the plot (with scaling). You can just add theme_gray(30) to your plots. One caveat to that. If you afterward set other parameters of text with them_text, you have to respecify the size.
Alternatively, you can take the code for theme_gray (or theme_bw, whichever is closer) and make any thematic changes directly there. For examples of how to do that, check the ggplot2 wiki: https://github.com/hadley/ggplot2/wiki/Themes
EDIT:
As an example:
library("ggplot2")
qplot(1:2,1:2) + theme_bw(30)

Resources