Changing font colors for syntax and a plotting question

Greetings all,

I would like to know a simple way to change the color of the syntax that is printed with Markdown. The code chunk is
<<echo=TRUE>>=
code here
@

It shows up as a very light blue against a light grey background. Is it possible to change the code color and/or the background?

Also, I am trying to change the height and width of some plots that were created with stan_plot (which uses ggplot). I'm using the 'egg' program with ggarrange but when I change the heights and widths specifications, nothing really changes. The code chunk is

library(egg)
library(gridExtra)
stanplot <- stan_plot(myfit, pars=c("alpha","beta1","sigma"))
stantrace <- stan_trace(myfit,inc_warmup=T, pars=c("alpha","beta1","sigma"))
standens <- stan_dens(myfit, pars=c("alpha","beta1","sigma"))
stanac <- stan_ac(myfit, pars=c("alpha","beta1","sigma"))
ggarrange(stanplot,stantrace,standens,stanac,nrow=2, ncol=2, heights=c(1,1),widths=c(1.5,1.5))
@

No matter what I do with the heights and widths numbers, it doesn't change the layout.Please ask your questions about R Markdown here.

Hello,

Are you using Rmd document ? Or maybe Rnw ?
What is your output ? PDF ? HTML ?

These informations are required to help with customisation of output.

Also having a reproducible example will help with issues.

(FAQ: What's a reproducible example (`reprex`) and how do I do one?)

Greetings,

I'm using a .Rnw document and typsetting with .PDF. I can't provide a reproducible example as it is a book manuscript. I am getting plots, however the heights and widths command don't seem to do much unless I remove them, and then the plots are really too big.

Thanks

David

Would you be able to build a small example with the command mentioning showing that it does not work ?

I unfortunately can't do much from here apart trying myself to build such an example to understand what is happening. Really not easy.

For the font color, a latex solution would work I believe. Did you try already ?

Example with Rmd:

Thanks for your response. I'll keep working on it. By the way, the color of the syntax can be set using a chunk such as

<<echo=FALSE,message=FALSE>>=
thm <- knit_theme$get("biogoo")
knit_theme$set(thm)
@

where there are many knit_theme options. See http://animation.r-forge.r-project.org/knitr/

David

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.