4
$\begingroup$

In four different experiments, I ran two programs A and B with different parameter setteings a, b, and c. Target variable is kind of time -- lower Target value means higher performance. I know the reasons why program A is better than B or vice-versa. Currently I am representing this data as tables in my latex document. However, I am not happy with this. I would like to provide a single figure which could show the difference between the parameter setteings effectively, and would be easy for the reades to get an idea of why A is better than B or vice-versa in a particular experiment.

Moreover, the units of the parameters a, b, and c are not the same. Thats why I don't like to use barplots for this problem.

It would be great if some one help for drawing a nice graph in R. Thank you.

Experiment-1
program & a & b & c & Target
A & 0.86  & 151 & 7 & 27 
B & 0.82 & 168 & 114 & 48 

Experiment-2
program & a & b & c & Target
A & 0.88 & 23530 & 67 & 154 
B & 0.79 & 23090 & 34 & 82 

Experiment-3
program & a & b & c & Target
A & 0.19  & 7855 & 172 & 53
B & 0.16 & 7398 & 189 & 104    

Experiment-4
program & a & b & c & Target
A & 0.30  & 5062 &301&  250 
B & 0.21 & 8797 & 443 & 198  
$\endgroup$

1 Answer 1

2
$\begingroup$

Here's something to play around with, next time do yourself a favor and don't make us figure out your data - provide us with a sample! :)

library(ggplot2)
cols <- c("a","b","c","target","program","experiment")
a <- c(0.86,0.88,0.19,0.30)
b <- c(151,23530,7855,5062)
c1 <- c(7,67,172,301)
targt <- c(27,154,53,250)
a2 <- c(0.82,168,114,48)
b2 <- c(168,23090,7398,8797)
c2 <- c(114,34,189,443)
targt2 <- c(48,82,104,198)
df <- data.frame(c(a,a2),
c(b,b2),
c(c1,c2),
c(targt,targt2),
program=c(rep("A",4),rep("B",4)), 
experiment=rep(1:4,4))
colnames(df) <- cols
df <- melt(df, c("program","experiment","target"))

ggplot(df, aes(target, value, color=variable)) + geom_point() + facet_grid(program ~ experiment, scales="free_x")
ggplot(df, aes(target, value, color=program)) + geom_point() + facet_grid(variable ~ experiment, scales="free")
$\endgroup$
4
  • $\begingroup$ Thank you. Sure, next time, I will provide a sample of my data. BTW, could you tell me how can I increase size of the points and also represent them with different pch values. $\endgroup$
    – samarasa
    Commented Aug 22, 2011 at 7:07
  • 2
    $\begingroup$ @kkp If the units of measurement are of no interest, why not simply showing the target difference A-B for each condition (superimposed on the same plot for the 4 labelled experiments)? $\endgroup$
    – chl
    Commented Aug 22, 2011 at 11:15
  • $\begingroup$ @kkp, actually, that's a good point. If the units don't matter, you could scale each one and have it all in one graph. $\endgroup$ Commented Aug 22, 2011 at 19:58
  • $\begingroup$ You can add a size argument inside geom_point(size=3). I'm not sure what you mean by represent them with different pch values. You mean vary size by some additional variable? It would look something like geom_text(aes(size=pch_values)) $\endgroup$ Commented Aug 22, 2011 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.