0

I am trying to compare two sets of data for multiple locations on an individual chart for each location.. data has structure

gw <- well.id    date    benzene    bgs 

bgs is depth to water (below ground surface) in feet. (I want to reverse this axis) benzene ranges from 3 to 9 in some wells, and from .0001 to .01 in others....

I want to plot benzene concentrations so they overlap with depth to water for a visual correlation between the two data sets...

please see this excel example plot: enter image description here

here you can find the data

aspects i have in mind are one data in reverse axis, scaled y values unique to each well location and data set... and the ability to pull subsets of the plots (like only the wells that show a correlations change in the most recent year)

I am approaching it like so...

setwd("~/my_ws")
gw <- read.csv("gw_cbp.csv")
gw


library(ggplot2) # Load the library

p <- ggplot(gw, aes(x=Date, y=Benzene)) + # Tell ggplot what you're plotting 
  geom_point() + #Tell ggplot it's a scatter plot
  geom_line() + # and i want lines
  facet_wrap(~ Well.ID) + # Plot one chart for each ID
  facet_grid(Date ~ Benzene, scales="free_y") ##not working... i know my syntax is wrong, just not sure how to fix it... 

p +
aes(x = Date, y = bgs)+
scale_y_reverse( y = bgs) # Reverse the axis
facet_grid(Date ~ bgs, scales="free_y")  ## still not working..

I know I am trying to scale my y axes individually, both unique to each location(well.id) and data set (benzene and bgs) and only one in reverse (bgs) as well as put the second y axis on the other side of the chart...but I am not getting it right.

as always, any help would be great,

ZR

Henrik
  • 65,555
  • 14
  • 143
  • 159
c0ba1t
  • 241
  • 2
  • 15
  • See also [**here**](http://stackoverflow.com/questions/3099219/how-to-use-ggplot2-make-plot-with-2-y-axes-one-y-axis-on-the-left-and-another) and [**here**](https://rpubs.com/kohske/dual_axis_in_ggplot2) – Henrik Dec 18 '14 at 17:12
  • I will look into them, thanks... might not be exactly what I need but will post back soon – c0ba1t Dec 18 '14 at 17:21
  • I have found what I need, I think... thank you for the info. I will post a specific answer when I hash it out. – c0ba1t Dec 18 '14 at 17:38

0 Answers0