Search code examples
rplotresizeperformanceanalytics

How to change size (width & height) of a plot produced by PerformanceAnalytics package in RStudio?


Here is the code:

charts.PerformanceSummary(dret_data, main='Portfolio Performance',
                      Rf=0.015/252, plot.engine='default')

Plot looks compressed in the notebook, snippet below (I would like to make it bigger): compressed plot in the notebook

When looking into the documentation nothing about plot resizing mentioned:

?charts.PerformanceSummary

Is there a way to work somehow around this issue and control witdh and height of the plot in the performanceAnalytics package in the R notebook?


Solution

  • If you're using an RStudio notebook for the code & output, you'll need to adjust the fig.width and/or fig.height in the chunk(or document) options.

    Below is the difference between fig.height 3 & 5:

    ```{r fig.height=3}
    library(PerformanceAnalytics)
    
    charts.PerformanceSummary(managers)
    
    ```{r fig.height=5}
    library(PerformanceAnalytics)
    
    charts.PerformanceSummary(managers)
    

    enter image description here

    Edit:

    Making the title larger:

    # Keep original par settings for later
    opar <- par()
    
    #change cex.main to whatever you want. Normal is 1.2 I think
    par('cex.main' = 2)
    #Plot now has larger title
    charts.PerformanceSummary(managers)
    
    # reset par settings 
    par(opar)