0

In the chemical data that we process, there are often two different ways to present the x-axis data. For instance, think of energy/wavelength, diffraction angle/length scale, or even simpler speed in mph/speed in kph.

These two sets of parameters have an obvious relationship to each other, that in most cases is not linear as in energy ~ 1/wavelength or d ~ 1/sin(theta).

A good example is this graph, where the authors have presented both wavelength and energy on the top and bottom x-axes.

How could I do this in R/ggplot2?

(note: my apologies. As this is my first question, I can't post images yet)

Rob Hanssen
  • 153
  • 8
  • 2
    [This](http://stackoverflow.com/q/21026598/324364) is most likely a duplicate, and probably the best solution you're going to get in ggplot2. The author of the package is philosophically opposed to dual x/y axis scales, so it is difficult to do by design. – joran Feb 26 '15 at 20:29
  • 1
    Also see [here](http://stackoverflow.com/q/18989001/324364) for more discussion. – joran Feb 26 '15 at 20:30
  • 1
    See [here](http://stackoverflow.com/questions/36754891/ggplot2-adding-secondary-y-axis-on-top-of-a-plot/36759348#36759348) and [here](http://stackoverflow.com/questions/36487283/ggplot2-2-1-0-broke-my-code-secondary-transformed-axis-now-appears-incorrectly/36761846#36761846) for code that works with ggplot v2.1.0. But no guarantees that it will work with future versions. – Sandy Muspratt Apr 21 '16 at 07:38

0 Answers0