Friday, June 1, 2012

Grace Tutorial: How to plot a graph with two different y-axes?

Say you have a dataset that looks like

x1, y1, Y2
x2, y2, Y2
...
xn, yn, Yn

and you want to plot (x,y) and (x,Y) with the same x-axis but different y-axes. As an example, consider the following graph (bigger versions of graphs upon clicking) where (x,y) are on a linear scale, and (x,Y) are on a logarithmic scale.

How do you make such a picture in Grace?

The strategy is very similar to making inset plots, which I wrote about a while ago. In fact, we could use essentially the same method, where the "inset" is the size of the main graph.

But we can do slightly better (and not have to deal with manually cleaning up extra tics) by using the "overlay" feature.

1. Read in the (x,y) dataset into the default graph G0 using Data -> Import -> ASCII dialog box.
2. In the same dialog box (Grace:Read Sets), right click on the "G0" graph, and choose "Create new" and create a new graph "G1"

3. Read in the other dataset (x,Y) into this graph. At this point, the graph looks somewhat garbled as seen below.

4. Click the Edit -> Overlay graphs to open up the overlay dialog box which looks like the following picture. I chose to overlay G1 on G0, and use a common x-axis. You can make different choices.

5. Once you do that, you essentially get what you need. You can go ahead and edit the appearance of the axes and sets. Since the graphs are on top of each other, it is sometimes hard to figure out which graph you are changing. Remember that clicking on the screen lets you toggle through the graphs. If you have widely varying y-axis (as in this example) you can figure out which one is active by looking at the co-ordinate marker right below main menu on the top left side.

6. Alternatively, you can open the Plot -> Graph appearance dialog box and changes the co-ordinates of the viewport so that the two graphs are non-overlapping. It makes clicking easier. You will have to repeat step 4, and undo changes to the viewport, once you've modified the graphs to your satisfaction.

9 comments:

The graphical representation in math is the best option to understand the problem or to solve the problem like linear equations solutions,limit and calculus,functions all are solved with the help of mathematics.