I have lots of datafiles I want to plot. gnuplot is scriptable. Since I don’t need any fancy output yet — this is data investigation, not manufacture of publication-quality diagrams — I can get multiple plots out quickly by writing a simple (simplish) couple of scripts.
I am sure people who know bash and perl and stuff can do this much better, but this works for me.
I have a wrapper script that simply consists of multiple calls to an inner script. It is here that I select the files I want to plot:
$ cat make_lots_of_plots.sh ./script_auto.sh r_0001_o_xy_TPA_21_Biso4p8_reread.inp ./script_auto.sh r_0001_o_yz_TPA_21_Biso4p8_reread.inp ./script_auto.sh r_0001_o_zx_TPA_21_Biso4p8_reread.inp . . etc . . ./script_auto.sh r_0050_o_yz_TPA_21_Biso4p8_reread.inp ./script_auto.sh r_0050_o_zx_TPA_21_Biso4p8_reread.inp
I know I could do this in a single script, but I like to be able to call the inner one directly if I just want to make one plot. The inner script, script_auto.sh looks like this:
$ cat script_auto.sh epsname=`basename $1 .inp`.eps echo $epsname scriptname=`basename $1 .inp`.gp echo $scriptname echo "set term postscript eps solid enhanced font 'Times,24'" > $scriptname echo $epsname > temp1111 echo 'set output "' > temp2222 echo '"' > temp3333 paste -d '' temp2222 temp1111 temp3333 >> $scriptname echo "set angles degrees; set polar" >> $scriptname echo "set size square" >> $scriptname echo "set xrange [-0.8:0.8]" >> $scriptname echo "set yrange [-0.8:0.8]" >> $scriptname echo $1 > temp1111 echo 'plot "' > temp2222 echo '" w l lw 3' > temp3333 paste -d '' temp2222 temp1111 temp3333 >> $scriptname echo "set output" >> $scriptname echo "set terminal x11" >> $scriptname echo "quit" >> $scriptname cat $scriptname rm temp1111 temp2222 temp3333 gnuplot $scriptname ls -ltrh $epsname
What’s going on here?
epsname=`basename $1 .inp`.eps echo $epsname scriptname=`basename $1 .inp`.gp echo $scriptname
The bit above just uses basename to create the two filenames I need, one for the encapsulated postscript output, and one for the gnuplot script. Then I basically assemble the lines I want to see go into the gnuplot script. Mostly I can just echo stuff into the file, but I have various quote marks within quote marks, and (for simple-minded me) the solution that I know works is to go via the paste command, and write stuff out to little text files. I am sure there are much tidier ways to do this, but this works for me.
paste -d '' temp2222 temp1111 temp3333 >> $scriptname
causes the contents of the temporary files to be pasted together and put into the script, where the delimiter (‘-d‘) is the thing between the single quotes — which is nothing since the quotes are adjacent. This pastes stuff together with no gaps. The things being echoed into the file are gnuplot commands of various kinds.
Then I cat the script to the screen so I can see what it is doing (if I direct the output from the plotting script into a file, this lets me capture the commands I used), then I remove the temporary files, run gnuplot, and list the newly made file.
Clunky, but simple and effective. Useful changes could include outputting to pdf or some other format, and adding a step at the end (perhaps using pdfjoin) to combine all the resulting files in a single file.
Here is a png of the result. The gnuplot formatting could be made much nicer (title is too big, etc), but the overall process can always be improved, so I’m not worried about that. And the fact that it is a script means I can replot quickly when I know what the final format should be. For now I just want to see what I’ve got.
Last year I joined the Canberra Society of Editors, CSE. Since I am not a professional editor (though I have acted in the role for a few publications) and I have no formal qualifications, I joined as an Associate Member. When I signed up the webform asked me what I might contribute to the society. I mentioned the things I knew something about, and newsletter editor Farid Rahimi came back suggesting that a message to the society newsgroup asking whether people would like to be introduced to LaTeX might be worthwhile. We sent the message, got a handful of responses, and, well…I wrote an article. It is here, the June 2015 issue.
Writing an article for a magazine whose readership consists entirely of people who specialise in finding errors in written English is scary. In the end I just had to forget about the audience, write it for a general reader, and then check it over fairly carefully. Fairly…
I decided that the topic was so wide that the best approach was to outline LaTeX’s main capabilities—logical mark-up, defining your own commands, cross referencing, good default text flow—then focus on LaTeX’s strengths and weaknesses as they pertain to editing. The change tracking facilities of modern WYSIWYG programs, most obviously Word, are very widely used tools—many modern editing textbooks have whole chapters walking the reader through the use of Word’s reviewing tools. Grammar checkers are also an issue. Equivalents to both of these tools can be found in the LaTeX universe, but they do not operate in familiar ways or provide like-for-like functionality. These things are real issues for editors.
In order to cover the ground I felt was important, yet not occupy the whole newsletter for several issues, I broke the content into two parts, a high-level review that was the actual article, and an example document that implemented many of the qualities to which I referred. The latter is available on my little download page here (cse_example.zip), a file bundle that includes all the source files needed to compile the document, including a gnuplot script that produces a graphic included using the gnuplot-lua-tikz package, a bibliography, mathematics, inputted files, and so on.