I am trying to plot the graph using ggplot2
So I have the following data set:
Experiment,Method,Values,Mean
10,IEEE802.11P,1,19.80
10,IEEE802.11P,5,21.91
10,IEEE802.11P,10,23.66
20,IEEE802.11P,1,16.03
20,IEEE802.11P,5,19.64
20,IEEE802.11P,10,27.81
40,IEEE802.11P,1,16.43
40,IEEE802.11P,5,27.65
40,IEEE802.11P,10,42.61
60,IEEE802.11P,1,17.06
60,IEEE802.11P,5,36.15
60,IEEE802.11P,10,49.87
80,IEEE802.11P,1,18.78
80,IEEE802.11P,5,41.70
80,IEEE802.11P,10,53.54
10,DTB-MAC,1,16.39
10,DTB-MAC,5,17.39
10,DTB-MAC,10,20.5
20,DTB-MAC,1,12.34
20,DTB-MAC,5,19.55
20,DTB-MAC,10,23.4
40,DTB-MAC,1,17.26
40,DTB-MAC,5,25.24
40,DTB-MAC,10,36.04
60,DTB-MAC,1,15.97
60,DTB-MAC,5,33.33
60,DTB-MAC,10,42.15
80,DTB-MAC,1,17.73
80,DTB-MAC,5,35.05
80,DTB-MAC,10,46.38
and here is the code for plotting:
library(grid);
library(ggplot2);
library(reshape2);
pdf(file = '$filename.pdf', width=5, height=5);
dat <- read.csv('bdr.csv');
ggplot(dat, aes(x = Experiment, y = Mean, colour = Method,
linetype = as.factor(Values), shape = as.factor(Values))) +
geom_line() +
geom_point()+
labs(x='$xlabel',y='$ylabel', fill='')+
scale_shape_discrete(name='Beacon Send Rate', breaks=c('1', '5', '10'), labels = c('1HZ', '5HZ', '10HZ')) +
scale_linetype_discrete(name='Beacon Send Rate', breaks=c('1', '5', '10'), labels=c('1HZ', '5HZ', '10HZ'))+
scale_y_continuous(limits = c(0, 100), breaks = (seq(0,100,by = 20)))+
theme_bw()+
theme( panel.grid.major = element_line(colour = 'grey'),
panel.border = element_rect(colour = 'black'),
axis.line = element_blank(),
panel.background = element_blank(), legend.direction='horizontal', legend.position='top', legend.background = element_rect(colour = NA));
the output is here:
https://www.dropbox.com/s/wpmyrkatnizer4b/look2.pdf?dl=0
but I have two problem:
1- the numbers in x.axis (variable Experiment) doesn't appear correctly. It must be 10, 20, 40, 60, 80 but the out put is 20,40,60,80.
2- Is there any method the mix the legends. For example in my case I have two groups of legends (1hz,5hz,10hz) and (DTB-MAC,IEEE802.11P) and make just one group with 6 items?