Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

quantmod barChart (or chartSeries) formatting options

Tags:

r

quantmod

I have just started playing with the quantmod package. The documentation is however, quite sparse (perhaps understandably, since it is OSS).

I am currently using barChart() which is a nice wrapper around chartSeries() and does most of what I want, but the default chart it produces are not quite what I want. To be specific, I want to tweak the charts produced by barChart() to suit my needs - however, since I am a newbie, I don't know whether my "tweaks" can be provided as options to the wrapper barChart(), or if I need to call chartSeries() directly, with specific arguments.

I have been tearing my hair out trying to do the following:

  1. replace the horrible {start date}/{end date} text in the top right hand of the chart produced by barChart() with text of my own choosing

  2. specify the formating to be used on the X axis (for example, show only the last two digits of the century. i.e. '98, '99, '00, '01 etc)

  3. 'Force' both top chart and the bottom chart to have their Y values printed on the left hand side of the chart

  4. Add an aditional series to the bottom chart

  5. Use different up/down colors for the bottom chart (defaults the using the same up/down colors for both top and bottom charts)

  6. Plot just the top chart (no bottom chart)

  7. Specify X axis, Y axis grid line spacings for top chart, for bottom chart

  8. Write the image to an alternative output (e.g. png image or pdf document) instead of the graphics device

Can anyone help with any (or all) of the above?.

like image 418
Homunculus Reticulli Avatar asked Feb 05 '12 12:02

Homunculus Reticulli


1 Answers

  1. This functionality isn't available (patches welcome).
  2. This functionality isn't available (patches welcome).
  3. This functionality isn't available (patches welcome).
  4. See the sparse documentation for ?addTA, specifically the on argument.
  5. Plot the bottom chart as two separate up/down series, using two different colors, or perhaps chartTheme.
  6. Not sure what you mean; just don't plot the bottom chart...
  7. See the sparse documentation for the major.ticks argument to chartSeries. I don't think you can change the y axis grid line spacings, and the x axis spacing will be the same for the top and bottom chart.
  8. See ?png and ?pdf.
like image 63
Joshua Ulrich Avatar answered Nov 01 '22 16:11

Joshua Ulrich