Question

I have this testdata :

      date      cpu_user cpu_id test1 test2 test3 test4
1 1386716402        U      U     U     U     U    31
2 1386716702        0   0.06 99.95  0.02 91.93    29
3 1386717002     0.01   0.04 99.97  0.03 19.46    29
4 1386717302     0.01   0.05 99.96  0.04 92.54    29
5 1386717602        0   0.04 99.97  0.04     U    29
6 1386717902        0   0.05 99.96  0.02 99.86    29

I want for example a freqpoly chart with date at x and the other(cpu_uder, cpu_id, ....) at y. Have someone an idea?

Thanks and best Regards!

Was it helpful?

Solution

d <- read.table(text=readClipboard(), header=TRUE, stringsAsFactors = T,
                na.strings = 'U')
df <- melt(d, id.var='date')
ggplot(aes(x=date, y=value), data = df) +
  geom_bar(aes(fill = variable), stat = 'identity', position = 'dodge')

bar chart

or

ggplot(aes(x=factor(date), y=value), data = df) +
  geom_bar(stat = 'identity', position = 'dodge') +
  facet_grid(variable~., scales = 'free_y', drop = F) +
  theme(axis.text.x = element_text(angle = 45, vjust = 1.1, hjust = 1.05))

faceting option

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top