quantmod icon indicating copy to clipboard operation
quantmod copied to clipboard

How to increase the chart dpi

Open hiteck88 opened this issue 3 years ago • 2 comments

Description

I am using Rmarkdown to generate the html output. However, the charts created by quantmod seems to have low dpi. I have tried to set dpi=300 in Rmarkdown knitr setting, but it has no effect. Could you please help with this? How to get the better quality of figures from quantmod in Rmarkdown output? Thanks

hiteck88 avatar Feb 19 '22 23:02 hiteck88

It would make it a lot easier to help if you provide a minimal reproducible example (i.e. not your entire Rmd file) and the output you get (the html and/or saved image). It's not clear whether this is something that can be fixed in quantmod or something that needs to be addressed with how you're using rmarkdown.

joshuaulrich avatar Feb 20 '22 18:02 joshuaulrich

Following [1] it is possible to adjust the dpi in Rmarkdown knitr with a configuration change:

out.format <- knitr::opts_knit$get("out.format")
img_template <- switch( out.format,
                     word = list("img-params"=list(fig.width=6,
                                                   fig.height=6,
                                                   dpi=150)),
                     {
                       # default
                       list("img-params"=list( dpi=150,
                                               fig.width=6,
                                               fig.height=6,
                                               out.width="504px",
                                               out.height="504px"))
                     } )

knitr::opts_template$set( img_template )

That might do the trick.

[1] https://stackoverflow.com/a/27321367

evelynmitchell avatar Jun 24 '22 23:06 evelynmitchell

I'm closing this because we don't have a reproducible example and/or evidence that this is something that can be fixed by a change in quantmod.

joshuaulrich avatar Mar 11 '23 20:03 joshuaulrich