joshuaulrich / quantmod

Quantitative Financial Modelling Framework
http://www.quantmod.com/
GNU General Public License v3.0
798 stars 219 forks source link

How to increase the chart dpi #355

Closed hiteck88 closed 1 year ago

hiteck88 commented 2 years ago

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

joshuaulrich commented 2 years ago

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.

evelynmitchell commented 2 years ago

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

joshuaulrich commented 1 year ago

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.