[R] kiteChart to show real values with scalebar

Jim Lemon jim at bitwrit.com.au
Sat Apr 28 13:29:49 CEST 2012


On 04/28/2012 04:12 AM, bodiless wrote:
> Dear R-users
>
> I hope someone could help me on this problem.
>
> I want to create a multiple kiteChart showing the real values with a
> scalebar on each indicating  the scale .
> Here are some sample data to show what I want to achieve.
>
> Y<- read.table(textConnection("Sample1 Sample2
>                                 60 20
>                                 150 50
>                                 300 100"),header=TRUE)
> X<- read.table(textConnection("Sample1 Sample2
>                                 6 2
>                                 15 5
>                                 30 10"),header=TRUE)
> par(las=1,mfrow=c(2,1))
> kiteChart(t(Y),xlim=c(-400,400),timelabels=c("2-3cm","1-2cm","0-1cm"),
>            normalize=FALSE,shownorm=FALSE,timex=FALSE)
> kiteChart(t(X),xlim=c(-400,400),timelabels=c("2-3cm","1-2cm","0-1cm"),
>            normalize=FALSE,shownorm=FALSE,timex=FALSE)
>
> My first problem with the above approach is that the kites in both graphs
> are overlapping. If I take out the xlim switch then the kites are too large
> and you can't see anything. If I use the xlim switch then they are not
> plotted next to each other as they should. Please note that I could use
> normalize=TRUE and then they are plotted ok but I don't want to normalize
> them.
>
> My second problem is that I have data which are way too smaller that the
> values shown in data.frame X. So, if the first graph has large values and
> the second very small values then on the second graph you see only a thin
> line. Therefore I want to multiply the small values of data.frame X by a
> factor to make the kites visible but then I need to place a scalebar on each
> graph showing e.g. that for the 0-1cm the top graph is 0-300 and the lower
> graph is 0-30.
>
Hi bodiless,
You have just contributed to the development of kiteChart. I have 
inserted another argument (varpos) that allows the user to place the 
"kiteline" along the axis orthogonal to the "time" axis. With the 
following code, I think you will get what you want.

kiteChart(t(Y),xlim=c(-400,400),
  timelabels=c("2-3cm","1-2cm","0-1cm"),
  normalize=FALSE,shownorm=FALSE,timex=FALSE,
  varpos=c(-100,300))
axis(3,at=c(-400,-100,200,300,400),labels=c(-300,0,300,0,100))


The last line puts axis tick labels on the top of the plot, which is 
what I think you want. The revised function is attached, let me know if 
any other mods are needed. The revised function will appear shortly in a 
new version.

Jim



More information about the R-help mailing list