Skip to content

R plot like candlestick

4 messages · Eik Vettorazzi, Denis Francisci, John Kane

#
Hi all,
I'm new on this list so I greet all.
My question is: does exist in R a plot similar to candlestick plot but
not based on xts (time series)? I have to plot a range of 4 value: for
every item I have min value, max value and 2 intermediate values. I
would like plot this like a candlestick, i.e. with a box between 2
intermediate values and 1 segment between box and min value and a
segment between box and max value. Candlestick plot is provided by
quantmod package, but it is very specific for financial purpose and it
uses time series for x axis. I need a simpler method for plotting my
data that are stored in a table like this:

item, min, int_1, int_2, max
a, 2.5, 3, 4, 5.5
b, 2, 3.5, 4, 4.5
c, 3.5, 4, 4.5, 5
.....

Does anyone know if there is an R-plot for this purpose?
Thank you very much,

D.
#
Hi Denis,
there is no "if", only "how" in R ;)

how about this:

rmail2<-read.table(textConnection("item, min, int_1, int_2, max
a, 2.5, 3, 4, 5.5
b, 2, 3.5, 4, 4.5
c, 3.5, 4, 4.5, 5"),header=T,sep=",")
with(rmail2,symbols(item, (int_1+ int_2)/2, boxplots=cbind(.25,
int_2-int_1,
int_1-min,max-int_2,0),inches=F,ylim=range(rmail2[,-1]),xaxt="n",ylab=""))
axis(1,seq_along(rmail2$item),labels=rmail2$item)

hth.

Am 28.01.2013 22:26, schrieb Denis Francisci:

  
    
#
Wonderful! Thank you Eik!
I thought there was a specific package or plot to get my purpose, but
your idea solves perfectly my problem.
Maybe I could try to write a simple R function using your suggest,
just to make fast my work. If I can get a result, I'll announce it in
this list.
Thank you very much.

Denis


2013/1/29 Eik Vettorazzi <E.Vettorazzi at uke.de>:
#
I have not had a change to look at the code but this appears to use ggplot2 to do something like what you want.  It may be of some use http://www.perdomocore.com/2012/using-ggplot-to-make-candlestick-charts-alpha/ .  The google search terms, ggplot2 candlestick, showed this and a couple of other possibly useful examples.

John Kane
Kingston ON Canada
____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM?, MSN? Messenger, Yahoo!? Messenger, ICQ?, Google Talk? and most webmails