I am using the Plots.text function from the Plots.jl package to annotate points in my plot. It appears that changing the plot(..., fontfamily="Computer Modern") does note seem to have an effect on these annotations.
Plots.text creates a text object including styling information. It is therefore necessary to change the font directly
Plots.text("abcde", "Arial")
seems to work
Related
Just started R a couple weeks ago. Getting familiar with ggplot. I successfully made the graph I wanted to including all legends, axes titles, etc. I'm able to export/save this image fine. However, the assignment also required me to change the font used for the title, axes, legend text, etc. on the graph. To import the font I wanted to use, I used showtext as I saw this recommended when I Googled. When I use this, it does change the font to what I want. However, although I can see the entire graphs and its two legends fine in the Plot viewer, when I go to export it, the legend text is now cut off on the right. This appears to be the case as soon as I load the showtext package and use showtext_auto(), even if I just try to then recreate the graph using R's default font, not even with the new font. I've spent tons of time playing around and can't seem to resolve this. Please help. Also would be preferable if there is a more permanent way to get fonts into R rather than me having to load showtext and whatever font I want each and every time. Thank you very much.
I am using Sweave and knitr together with <<dev="tikz">>= for figures. For simplicity, I first will try to explain my problem without providing a minimal working example:
I am using the command acf for plotting an autocorrelation function and want to change the font of the main title to e.g. font.main=1. I looked up the documentation which tells me that additional arguments of acf are the same as for plot.acf, which in turn uses the same as plot. Therefore I think font.main should work for acf as good as it does for plot. Unfortunately, adding an additional parameter for font.main in acf has no effect on the font of the main title. However, in plot this works fine. What is wrong here?
Something seems odd because the documentation of acf states that ... are "further arguments to be passed to plot.acf". And, the documentation of plot.acf further states that ... are "graphics parameters to be passed to the plotting routines".
This seems partially correct as passing font.lab and font.axis appear to produce the intended effect. However, font.main is ignored for reasons yet to be uncovered.
Until this gets fixed, the solution is to change the graphical parameters first, then run the command.
op <- par(font.main=1, ...)
acf(...)
par(op) # change back
I have a LaTeX/knitr document that I need to convert to PDF/A, but I'm getting errors about transparency being used (which is not allowed in PDF/A). I traced it back to the background fills of the boxplots that I'm generating in R via knitr. Regardless of whether I use "pdf", "cairo_pdf" or "tikzDevice" as the output device, the same error results.
The Tikz output includes the following:
\definecolor{fillColor}{RGB}{255,255,255}
\path[use as bounding box,fill=fillColor,fill opacity=0.00] (0,0) rectangle (505.89,325.21);
Manually removing the fill opacity=0.00 part and rerunning only pdflatex gets rid of the message for a particular graph, so I'm pretty sure that's the cause. However, I'd prefer to make the change in the source file (R code), so I don't have to manually make this fix every time the source changes and the intermediate files are regenerated.
Does anyone know the magic option to feed bxp or par in R that would translate into an opacity of 1.0, or, better still, specify no fill at all? (The fill is completely unnecessary, given that it's a white background being placed on an empty part of a page.)
(BTW, I tried bg=NA in the bxp call, and par(bg=NA) before, and neither had any effect. For that matter, using "red" also had no effect, so that doesn't seem to be the right option.)
Apparently, the bg in the graphics parameters (par=) only applies to objects within the plot (like the boxes in a boxplot). The background for the whole plot is set in knitr's dev.args chunk option, e.g., globally:
opts_chunk$set(dev='tikz', dev.args=list(bg="white"))
or at the start of a particular chunk. It appears there's no way to drop the fill option entirely (there's a "TODO" item in the tikzDevice source code), but changing it to "white" has eliminated the PDF/A validation errors, with no visible effect on the document. Once my thesis is in, maybe I can submit a patch for this. :-)
I have a line chart in Gadfly using the label = "string vector" option. My question is how can I manipulate the location and size of the labels printed on the chart? I want to adjust the location of the printed labels upward slightly and increase the font size. How can I do this?
From the Gadfly documentation, I think it should be an option within 'Theme', but I can't seem to figure this out.
http://gadflyjl.org/themes.html
Thank you
As mentioned by #jfish003 there is a named argument in Theme, major_label_font_size which can be set as needed. The font size of minor label can also be set. Note that the argument is of type Measure, a simple example,
julia>plot(x=rand(10), y=rand(10), Theme(major_label_font_size=15pt))
The manual (pdf) doesn't seem to indicate any parameter responsible to change the labels' color. To be clear, I'm not referring to the numbers on the axis, but to the labels at the edges of the polygon.
I've used the first example taken from the solution given to this question.
I tried:
par(col.lab="grey")
before or after calling radarchart function, but it didn't work. The labels remained black.
The solution was to insert the following snippet just before calling the radarchart() function:
par(col="grey")
Doing so one changes the specification for the default plotting color.
See here for more.