As the title, I need to wrangle the plot so that all the words are typed in the font style of Arial. How do I do that? Sorry for the late edit. This question was meant for the EnhancedVolcano plot package.
As the title, I need to wrangle the plot so that all the words are typed in the font style of Arial. How do I do that? Sorry for the late edit. This question was meant for the EnhancedVolcano plot package.
Just in case other users happen to encounter similar issues, here are my five cents on the topic:
Looking at the EnhancedVolcano()
code, I don't see why there would be different fonts in the labels; they should all have the same basic font (which may or may not be Arial-like; see below) because the main function seems to rely on bquote()
and ggplot2::geom_text()
for generating the labels.
ggplot2::geom_text()
uses the "sans" family of fonts per default. You can learn a lot about the details in the documentation and here
To find out which font will be used on your computer for the "sans" entry, you can try X11Fonts()$sans
if you're working on a Mac or Linux-based OS. More here
In my case, the output looks like this:
> X11Fonts()$sans
[1] "-*-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"
Therefore, my plots are labeled with Helvetica, which is essentially Arial (see below for more on that).
You could indeed ask the author of EnhancedVolcano
to expose the font family parameter of ggplot2::geom_text()
to the user -- this is best done via github --> issues where you can ask for a new feature with the package.
A quicker solution may be to try the base R PDF export function with specifying the font family:
ggp <- EnhancedVolcano(...)
pdf("ggp.pdf", family = "Helvetica") # Apply pdf function
print(ggp)
dev.off()
However, pdf()
typically offers support for standard Adobe fonts (and URW equivalents), which does NOT include Arial (the closest will be Helvetica -- I dare the reviewer to spot the difference although they do exist)
From help(pdf)
:
these are fonts you can specify via the
family
parameter: "AvantGarde", "Bookman", "Courier", "Helvetica", "Helvetica-Narrow", "NewCenturySchoolbook", "Palatino" and "Times"; "URWGothic", "URWBookman", "NimbusMon", "NimbusSan" (synonym "URWHelvetica"), "NimbusSanCond", "CenturySch", "URWPalladio" and "NimbusRom" (synonym "URWTimes").
This also means that even if EnhancedVolcano
exposed the ggplot2::geom_text()
parameter to change the font family manually, you'd be stuck with whatever is available on your system. If you truly want to go down the rabbit hole of installing additional fonts, you will have to look into additional packages, such as extrafont
. I do not recommend this, though.
In brief: Make sure your settings for the "sans" family specify "Helvetica" (or "Arial", of course).
The easiest solution, btw, might be to simply specify your own labels via EnhancedVolcano
's xlab
, ylab
, subtitle
parameters because I'm suspecting that the issue the reviewer has may be with the use of bquote
as the default setting and the subsequent proper display of mathematical notation which some reviewers may not be used to anymore. However, even those font settings simply rely on your environment setting:
The fonts used are taken from the current font family, and so can be set by par(family=) in base graphics, and gpar(fontfamily=) in package grid.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Since Enhanced volcano is based on ggplot2, ggplot2 options might be working over enhanced volcano object Try this:
=
If you have problems in importing fonts, try font_import after installing 'remotes::install_version("Rttf2pt1", version = "1.3.8")'
To make this question more legible/get a greater audience, you should
I'm relatively certain that we could help you here, but you need to be more specific about which part of the labels you're actually taking issue with.
Past threads that are related to fonts for EnhancedVolcano that may be useful:
Enhanced volcano: how to italicize or change the font of legend?