next up previous contents
Next: 4.3 Example 2: Connected Up: 4. Using frames Previous: 4.1 Introduction

   
4.2 Example 1: Using two different y-axes

In this example, we will use frames to produce a plot that uses two different y-axes to display two different data sets. One y-axis labeling will be on the left hand side of the view graph, the other one on the right hand side. The resulting plot is shown in figure 4.2. Here we display the scaling factor f (right axis) and the background parameter b (left axis) of a Reverse-Monte-Carlo refinement as function of the cycle number as an example plot.


  
Figure 4.2: Using different y-axis with frames
\includegraphics[scale=0.5, angle=270.0]{fra.2.eps}

We will discuss the corresponding macro file listed below step by step. Again the line numbers are not actually part of the macro. Lines 1-6 are nothing special, we read the two data files and set common features like title lines. Next we set the number of frames to two (line 8). Since we want to plot the two data sets on top of each other using just a different y-axes, we have to overwrite the default location of the frames using the 'sfra' command (lines 10-11). The coordinates of the plot area range from 0.0 to 1.0 in x- and y-direction. In our example both frames cover the complete plot area.

     1  load xy,back.xy
     2  load xy,scal.xy
     3  #
     4  fnam off
     5  tit1 RMC test simulations
     6  tit2 Frame demonstration
     7  #
     8  nfra 2
     9  #
    10  sfra 1,0.0,0.0,1.0,1.0
    11  sfra 2,0.0,0.0,1.0,1.0
    12  #

The next step is to input the settings for both frames. First we set the input focus to frame 1 (line 13) and specify data set 1 to be used in that frame (line 14). The 'fset' command in line 15 determines the layout of the view graph and setting number '3' is the default plot layout, i.e. box, labels and tick marks in x- and y-direction and lines at x=0, y=0. Finally we set the size of the plotting window (line 16), the tick mark intervals (line 17) and the labels for the axes (lines 18-19).

    13  afra 1
    14  kfra 1,1
    15  fset 3
    16  skal 0.1,30.0,0.0,7.0
    17  mark 5.0,1.0
    18  achx RMC cycle number
    19  achy Background b
    20  #

The same as before has to be done for the second frame. Lines 21-22 set the focus to the second frame and select data set 2 to be displayed. The negative value of the parameter of the 'fset' command (line 23) indicates that the y-axis label and numbers are to be plotted on the right hand side rather than on the left hand side which is the default. Again the extend of the plotting window and the tick marks are set (lines 24-25). Note that we need to specify the same plotting range ( $0.1 \rightarrow 30.0$) in x-direction and a different one in y-direction compared to the settings of frame 1. The x-axis label is switched off (line 26) because we have already the label from the other frame. The y-axis needs a new label (line 27). Finally we define two annotations (line 28-29). Note that the given coordinates are with respect to the scaling of frame 2.

    21  afra 2
    22  kfra 2,2
    23  fset -3
    24  skal 0.1,30.0,15.0,21.0
    25  mark 5.0,1.0
    26  achx
    27  achy Scaling factor f
    28  sann 1,"(b)",10.0,15.5
    29  sann 2,"(f)",17.5,20.0
    30  #
    31  plot

Obviously the same plot could have been achieved by scaling one of the data sets to the y-range of the other, but the information about the original range of y-values of one of the data sets would have been lost in the plot in contrast to the example using frames given here.


next up previous contents
Next: 4.3 Example 2: Connected Up: 4. Using frames Previous: 4.1 Introduction
Thomas Proffen {Billinge}
1999-06-26