[R] Bode plots in ggplot2

Tribo Laboy tribolaboy at gmail.com
Thu Feb 7 11:57:20 CET 2008


Hello,

I am trying to figure out how to make a bode plot (a.k.a. bode
diagram) in ggplot2.

An example of such a diagram can be found here:

http://meweb.ecn.purdue.edu/~me475/ctm/freq/bode2.GIF

The example above shows the gain and phase characteristic of a linear system.
In my case, I would like to compare visually several systems on the
same diagram.


The data in the data frame is arranged like this:

frequency | gain | phase | system
0.0 | 1.0 | 0.0 | system 1
0.5 | 1.2 | -0.1 | system 1
1.0 | 1 .4| -0.2 | system 1
.
.
0.0 | 2.2 | 0.0 | system 2
0.5 | 2.2 | -0.5 | system 2
1.0 | 2 .4| -0.6 | system 2
.
.
.

First problem is, I would expect I'll need to use layers (for each
"plot", "panel", "axes", whatever it is called)  in ggplot, but I
don't know how.
The second problem is that those two "panels" need to have a common
legend (or "key"), which says "system 1" "system 2" . And that doesn't
seem to be trivial either.

Any help appreciated,


Regards,

TL



More information about the R-help mailing list