0

I have this data frame, called test. It has 3 columns, DATE, USED_CORES, RELATIVE_PERCENT. I would like to create a ggplot graph where I would like to show DATE on the xaxis, RELATIVE_PERCENT on the yaxis and USED_CORES on the right side of the yaxis.

This is my data frame:

dput(head(test,30))  

structure(list(DATE = structure(c(1364359560, 1364359590, 1364359620, 
1364359650, 1364359680, 1364359710, 1364359740, 1364359770, 1364359800, 
1364359830, 1364359860, 1364359890, 1364359920, 1364359950, 1364359980, 
1364360010, 1364360040, 1364360070, 1364360100, 1364360130, 1364360160, 
1364360190, 1364360220, 1364360250, 1364360280, 1364360310, 1364360340, 
1364360370, 1364360400, 1364360430), class = c("POSIXct", "POSIXt"
), tzone = ""), USED_CORES = c(2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 
2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.24, 2.4, 2.4, 2.4, 2.4, 2.4, 
2.24, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.56), 
    RELATIVE_PERCENT = c(15, 15, 15, 15, 15, 15, 15, 15, 15, 
    15, 15, 15, 14, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 
    15, 15, 15, 15, 15, 16)), .Names = c("DATE", "USED_CORES", 
"RELATIVE_PERCENT"), row.names = c(NA, 30L), class = "data.frame")

I can do this to show DATE on the xaxis and RELATIVE_PERCENT on the yaxis:

ggplot(test, aes(DATE, RELATIVE_PERCENT)) + 
      geom_point(colour="blue", size=1) + theme_bw()

How can I show the USED_CORES in the right side of the y-axis?

Julius Vainora
  • 47,421
  • 9
  • 90
  • 102
user1471980
  • 10,127
  • 48
  • 136
  • 235

1 Answers1

1

Apparently this is not possible in ggplot2 for a good reason. Have a look at this question:

Plot with 2 y axes, one y axis on the left, and another y axis on the right

And especially at the wiki-link from the accepted answer:

http://rwiki.sciviews.org/doku.php?id=tips:graphics-ggplot2:aligntwoplots

Community
  • 1
  • 1
dlaehnemann
  • 671
  • 5
  • 17