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.
R plot like candlestick
4 messages · Eik Vettorazzi, Denis Francisci, John Kane
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:
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.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus
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>:
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:
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.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Martin Zeitz (Vorsitzender), Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus
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
-----Original Message----- From: denis.francisci at gmail.com Sent: Mon, 28 Jan 2013 22:26:02 +0100 To: r-help at r-project.org Subject: [R] R plot like candlestick 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.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________ 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