Spider Plot using ggplot

275 views
Skip to first unread message

Pankaj Agarwal

unread,
Feb 14, 2016, 6:44:35 PM2/14/16
to ggplot2, p.ag...@duke.edu
Hi,
I am new to using ggplot (R plotting in general) and trying to create a Spider Plot with ggplot.
The best I could do looks like using the following code:

> df=read.table("spaghettiPlotDataTest.tsv", header=T, sep="\t")
> str(df)
'data.frame':   31 obs. of  3 variables:
 $ Sample : int  1 2 3 4 5 6 7 8 9 1 ...
 $ Days   : int  0 0 0 0 0 0 0 0 0 30 ...
 $ Outcome: num  0.848 0.883 0.831 0.788 0.824 ...
>
> p = ggplot( df, aes( df$Days, df$Outcome, group=df$Sample ) ) +
+ geom_line(color=df$Sample)
> p
I am trying to get a legend on the right and also the following:
 - change x y labels
 - circles or some other shape at the point where two different lines join.
 - specify the thickness of the lines, different for different samples if possible.
 - control the color of the lines, different for different samples groups if possible.

An example of what I am trying to achieve is given in Figure 2 of the following link:

The full data set is attached.

Thank you for your help.

- Pankaj


spaghettiPlotDataTest.tsv

romunov

unread,
Feb 15, 2016, 1:31:42 AM2/15/16
to Pankaj Agarwal, ggplot2, p.ag...@duke.edu

Hi,

- see xlab() and ylab()
- you will have to calculate intersection points and plot circles on those coordinates
- map line thickness in aes() to that variable
- ibidem

You might want to check out http://docs.ggplot2.org/current/

Cheers,
Roman

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages