Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot example in 06 #1365

Open
bkmgit opened this issue Feb 13, 2023 · 1 comment
Open

Plot example in 06 #1365

bkmgit opened this issue Feb 13, 2023 · 1 comment

Comments

@bkmgit
Copy link
Contributor

bkmgit commented Feb 13, 2023

The plotting example in 06 could be improved to be more realistic. For example by using graph from plotutils if it is available in all environments.

@arendsee
Copy link

@bkmgit Did you have something like this in mind:

We can generate plots on the command line with the plotutils package. You can install this package with:

$ sudo apt-get install plotutils

Returning the gyre dataset, say we want to compare each the A and B files from each dataset. We can join two of the columns with the paste command:

$ paste NENE01751[AB].txt | graph -T png -m 0 -S 3 -X "A values" -Y "B values" -L "NENE01751 A vs B" > NENE01751.png

The -T option sets the output format. We choose png. The default format is "meta", which, as the documentation graph --help helpfully tells us, is probably not what we want.

The -m 0 option sets the format of the lines between points. We want a scatterplot. we set this to zero indicating no lines between points. You can experiment with other values (1,2, ...).

The -S option sets the shape of the points in the plot. We chose 3, which represents data points with X's.

The -X, -Y and -L options set the x-label, y-label, and main plot title, respectively.

We can wrap this in a shell script:

for file in *A.txt
do
    name=${file//A.txt}
    paste ${name}A.txt ${name}B.txt | graph -T png -m 0 -S 3 -X "A values" -Y "B values" -L "$name A vs B" > $name.png
done

The ${file//A.txt} command is a Bash shortcut to remove the exact string "A.txt" from the end of a variable. In this case, it lets us convert from "NENE01751A.txt" to "NENE01751".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants