Is there an Rstudio-specific way to specify the default font size? Since Rstudio has other panels that use up space, I'd like to have a smaller font size than I would have for other ways of using R.
Go to Tools | Options | Global Options. There you can set the font. As far I can tell this persists between sessions.
Also see here.
RE #Dank's note: sorry, I see now that you mentioned plots in the question.
I think this cannot be controlled globally in RStudio, but depends on the specific graphics package you are using. So using plot(...) in base R you would use:
par(ps=10) # default starts out at 12
This sets the default point size to 8 points until you use par(...) again.
If you are using ggplot, see this link.
Hope this helps.
You may use teh parameter cex , for example
cex=0.7
it decreases the font relatively to the default font.
Related
This is a workflow related question. I'm trying out working only (or mostly) in the Rmarkdown source window with the options set to "Chunk output inline". So with R open, there is just one big window -The environment, Console and File windows being minimized.
My question: Is there some option to change the number of columns displayed? I want to increase the numbers of columns visible without scrolling (see screenshot below), and since there is enough space I think it should be possible to display more of them.
Many thanks!
Solution: There is an option. Just add cols.print = 12 (or whatever number you want) to global options.
Also, people might find this 'manual' on markdown useful: https://bookdown.org/yihui/rmarkdown/html-document.html#paged-printing
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
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
I have a 2k lines script that generates several complex plots (plots in plots, custom plot functions etc).
I would like to change the default font to Times New Roman or Arial. Is it possible to do it globally or on a per session basis? I can't go through my script and change every plot() or text() etc. Thanks
You could change the settings at the beginning of your session using par(family="the-font-you-want"). If not overwritten afterwards this will affect all the plots in your session.
par(family="HersheyGothicEnglish")
plot(1:10, main="Stylish Font Family")
The number fonts that come along in R are quite limited though (see family parameter in ?par). You can extend the number of fonts you can apply (to use e.g. Arial) using the extrafont package.
Here you will find a good explanation of how to do that.
Is there a method for specifying the font size in when producing figures in R. This seems like a really basic requirement but I can't seem to find any references to somewhere that specifies the font size. I can save a figure to a pdf as follows:
setwd("C:\\")
pdf(file="Plot.pdf",family="Times")
plot(x,y);
dev.off()
Where R basically generates the figure in the pdf not in the figure window. When I look for ways of altering the font size all I see is people referring to cex=1.5 argument to scale fonts 150 percent, and cex.lab, cex.axis, etc ... Although not being an immediate issue now, I do wonder what will happen when I publish some results and the journal requires font size between 9 and 11. How do I control these in R? Any suggestions would be appreciated.
You control the font size with the ps (point size) parameter. The default is typically 12 (but can be controlled globally for a PDF file by the pointsize parameter) so if you want, let's say, fonts of the size 10 for a particular text you would use par(ps=10); text(...). Since you mentioned cex: note that cex is relative to the current pointsize and also applies to symbols whereas ps specifically applies to text. Obviously, the size will only match as long as you don't resize the resulting figure.