lundi 13 février 2017

how to use ggplot in R to draw a single graphic with two lines and one area with duo y axis?

Vote count: 0

I'd like to draw a combo graph where

  1. the x-axis is the hour of the day
  2. Two lines represent the average value of each hour
  3. A filled area represents the volume of the data points of each hour
  4. Two y-axis as the units of the avg. value and the count are different

here's some fake data:

 data = data.frame(x_hour=c(8,9,10,11,12,13,14,15), 
 y_linea=c(3,7,6,8,14,16,18,12),
 y_lineb=c(3,5,12,7,4,6,19,9),
 y_count=c(50,70,120,60,85,48,36,70))

and here's the ideal picture I wanted to draw

My thought was to draw two separate graphs and combine them together, but I cannot figure out how to create the graph with the area or how to combine those two graphs. I would appreciate it a lot if you could share your ideas with me, thank you!

asked 47 secs ago

Let's block ads! (Why?)



how to use ggplot in R to draw a single graphic with two lines and one area with duo y axis?

Aucun commentaire:

Enregistrer un commentaire