[R-SIG-Finance] Modify the chart object to save plotted text

Joshua Ulrich josh.m.ulrich at gmail.com
Thu Apr 19 02:45:11 CEST 2012


Stergios,

On Wed, Apr 11, 2012 at 11:31 AM, Stergios Marinopoulos
<stergios_marinopoulos at yahoo.com> wrote:
>
> [I originally posed this question under a different thread regarding ablines, but I imagine the question was different enough that it went ignored, so I will try again using a new thread.]
>
>
> How can I alter the underlying chart object so that text annotations are not lost when the plot is re-drawn, like for example when a call to addTA is made?  (I am using the experimental versions of the charting api in quantmod)
>
> Here's how I currently add text to a chart:
>
> getSymbols("SPY", from="2012-01-01", to="2012-04-01")
> chart_Series(SPY)
> x <- SPY["2012-02-15", which.i=TRUE]
> text(x, Lo(SPY)[x,], "2012-02-15", srt=90, adj=c(1,0.5) )
>
>
> And now when I add this TA the text disappears:
>
> add_TA(Cl(SPY)<134,border=NA,col='#888888',on=-1)
>
> I think this probably requires going under the hood in the library, so a pointer on where to begin looking would be greatly appreciated.
>
I'm not familiar with the internals of chartSeries or chart_Series, so
I can only provide a pointer.  Look at add_TA to see how it gets the
current plot object and adds to it.

> Thanks,
>
> sm
> --
> Stergios Marinopoulos
>

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com

R/Finance 2012: Applied Finance with R
www.RinFinance.com



More information about the R-SIG-Finance mailing list