Hello,

I'd like to customize the makeChart function output of the quantmod
library.  Its main objective is threefold:

1. have x axis labels at 45 degree angle.
2. have a title and subtitle
3. have labels legends.

I can obtain the desired output via the ggplot code below.  However, the
chartSeries() function doesn't work. port_cumulative_ret along with the
other data required are obtained via tiidyquant library.

port_cumulative_ret %>%
    ## axis data
    ggplot(aes(x = date, y = cum_ret)) +
    ## plot configuration
    theme_gray() +
    theme(plot.background = element_rect(fill = "gray86")) +
    geom_line(color = "blue") +
    theme(axis.text.x = element_text(angle = 50, hjust = 1)) +  ## x axis
text at 45 degree angle
    ## graph text, notation and number settings
    labs(x = 'Data',
            y = 'Cum Return',
         title = paste0('Portfolio Cum Return on ', format(as.Date(end),
format="%m/%d/%Y")),
         subtitle = paste0("Actives: ", toString(tickers.clean),
"\nWeights: ",
                           toString(percent(wts, accuracy = 0.01)))
         ) +
    ## axis numbering settings
    scale_x_date(date_breaks = '2 weeks',
                 date_labels = '%d %b %y')
    )

Thanks in advance for any help.

--
André Luiz T. Ramos, PhD

        [[alternative HTML version deleted]]

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to