how to use xmgrace to plot histogram from a plot

xmgrace

Solution

You nearly had it! Here is a full step-by-step solution: Save the data in a two-column file "sample.dat". Here are the contents of such a file:

#n  angle
1   13
2   -162
3   -63
4   53
5   -170
6   80
7   173
8   39
9   113
[ etc ...] 

In my example file I have 40 entries with randomly-generated angles. Call xmgrace from the command line and load the data file:

xmgrace sample.dat

At first you will see a line plot of angle vs n. We can bin the data and plot a histogram as follows:

Data > Transformations > Histograms

This will open a new window titled "Grace: Histograms". Right-click on your data set "G0.S0" and duplicate it. On the left-hand panel select the original data set by left clicking once. On the right-hand panel select the new data set "G0.S1".

Now at the bottom of the window choose your binning parameters.

Start at: -180

Stop at: 180 

# of bins: 5. 

Click `Apply`. The histogram is now plotted but the original line plot needs to be hidden. In the left-hand panel right-click on the original data set "G0.S0" and choose "hide".

After all of these steps the "Histograms" window should now look like this:

Finally, in the main xmgrace window, rescale the plot. You should now see the histogram, with your angles binned into five bins. The angle ranges are shown on the x axis and the frequency of each bin range on the y axis. Here is the default output where I have labelled the axes:

The total of the frequencies from all bins should add up to the number of data lines in sample.dat.

Problem

I have a text file (say, sample1.dat) with two columns:first column is a serial no running from 1 to 5000 and second column consists of 5000 dihedral angles varying in between -180 to 180 in degree. By using the command ``` xmgrace sample1.dat ``` I got a plot of dihedral angle vs.serial no. To get the histogram from the plot, I did the following in the pop up window of Grace: `Data -> Trasnformation -> Histograms` In the newly pop up window called `Grace: Histograms`, I selected the `source` graph but did not select any in the `destination` graph as explained somewhere in grace tutorials. After selecting start as -180, stop as 180 and number of bins as 5 and then hitting the `Accept` command in that window, I got the following error message: ``` [Error] Please select single source and destination graphs ``` Help me to get the histogram from the plot. I want to use `xmgrace` to plot the histogram. I know how to plot it using some widely used plotting tools like gnuplot and others.

Original source