Xmgr annotations

| categories: xmgr | View Comments

Frankly, I think that xmgr is obsolete. It had some grace (pun intended) 10yrs ago, and it still produces very consistent graphs. But it smells like an old cheese, it lacks latex/regexps/modern scripting language/importing of modern binary formats/2D heat maps. Nevertheless, if I happen to have an ascii data file around, I am still tempted to launch it once in every while. GMT will take you further, but xmgr will take you faster (once you get the hang of its awkward arrangement of menus).

This guy summarizes for us some of the very basic subtleties of xmgr's gui. The most important for me are related to special chars:

The old way of including special chars/fonts :

What example
superscript x\S2\N
Subscript 3\s10\N
Greek letters (e.g. theta) \f{Symbol}q\f{}
Special symbols (e.g. Angstrom symbol) \cE\C

The new method to insert special characters in xmgrace is:

Press ctrl-e while positioned in a text-edit field to bring up the font dialog box, and select whatever you want.

Thanks Louic .

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments

The best of all worlds - disp + sprintf

| categories: matlab, octave | View Comments

Going through loops you would often find yourself writing something ugly like :

1: n=10;
2: is_verbose=true;
3: for i=1:n
4:  if(is_verbose)
5:   disp(sprintf('DBG: %d/%d',i,n));
6:  end
7:   % some interesting stuff here....
8: end
>> >> DBG: 1/10
DBG: 2/10
DBG: 3/10
DBG: 4/10
DBG: 5/10
DBG: 6/10
DBG: 7/10
DBG: 8/10
DBG: 9/10
DBG: 10/10
>>

While, if you had disp and sprintf combined, you could have written a beautiful code like this :

1: is_verbose=true;
2: n=10;
3: for i=1:n
4:  verbose_disp(is_verbose,'DBG: %d/%d',i,n);
5:  % some interesting stuff here....
6: end

Thanks to Matlab's varargin this little gem could be very close to sprintf in syntax.

 1: % purpose display only if the script is in verbose mode + include sprintf 
 2: % capabilities in disp.
 3: % syntax : verbose_disp(flag_verb,form,[variable_list])
 4: % flag_verb=1 if you want to display, and 0 if you don't want to
 5: % display
 6: % form = string including formatting directions for sprintf 
 7: % variable_list = more parameters which include variables fitting
 8: % into the format "form".
 9: %
10: % see also : disp, sprintf
11: 
12: % Copyright 2013 Avi Gozolchiani (http://tiny.cc/avigoz)
13: % This program is free software: you can redistribute it and/or modify
14: % it under the terms of the GNU General Public License as published by
15: % the Free Software Foundation, either version 3 of the License, or
16: % (at your option) any later version.
17: %
18: % This program is distributed in the hope that it will be useful,
19: % but WITHOUT ANY WARRANTY; without even the implied warranty of
20: % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21: % GNU General Public License for more details.
22: %
23: % You should have received a copy of the GNU General Public License
24: % along with this program.  If not, see <http://www.gnu.org/licenses/>.
25: 
26: % $Log$
27: function verbose_disp(flag_verb,form,varargin)
28: % little input checking
29: if(nargin<2)
30:     error('verbose_disp : wrong number of arguments');
31: end                                     % if(nargin<2)
32: if(~ischar(form))
33:     error('second argument should be a character string');
34: end                                 % if(~ischar(form))
35: % if mode=verbose display the formatted string
36: if(flag_verb)
37:   s=sprintf(form,varargin{:});
38:   disp(s);
39: end % if(flag_verb)

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments

linux copy to clipboard

| categories: alias, workflow, osx, linux | View Comments

Is it true that you have to give names to things to really appreciate and understand them? It's really one of these questions that are just too gross for answering a straight yes or no.

When you think of this question, math comes to mind. I have little doubt that you must internalize dozens of definitions and the relations between them before you master differential geometry, or group theory. But do you need language to understand subtraction? The answer is - NO . Babies do it intuitively. So there is some border beyond which things become too abstract, and we've got to give them names. But isn't my answer a tautology? Isn't "abstract" just the name of this phenomena of having to name something in order to understand it? Sure enough, if we were not so used to giving names to everything, we would have found lots of things "abstract". Helen Keller writes :

"my teacher placed my hand under the spout. As the cool stream gushed over one hand she spelled into the other the word water, first slowly, then rapidly. I stood still, my whole attention fixed upon the motions of her fingers. Suddenly I felt a misty consciousness as of something forgotten - a thrill of returning thought; and somehow the mystery of language was revealed to me. I knew then that "w-a-t-e-r" meant the wonderful cool something that was flowing over my hand"

Most of us don't think of the notion of water as abstract, but it's just a matter of experience.

SO… It didn't occur to me that I need to copy linux outputs to the clipboard, until I found out about xclip (keep your comments about the long intro to yourself, by the way…). Now that I know about it, I also care about cases where I want the trailing '\n', and cases where I don't.

Here are my aliases for linux:

1: alias xc='xclip -selection clipboard'
2: alias xcn='perl -ne "chomp();print" |xclip -selection clipboard'

And here they are for mac osx :

1: alias xc="pbcopy"
2: alias xcn="tr -d '\n' | pbcopy"

The two approaches for removing the newlines work equivalently on both systems.

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments

latex automatic rotation

| categories: latex | View Comments

The usual workflow with a latex document is latex->bibtex->latex->dvips->ps2pdf. There are some variations, on this theme. Anyway - when you use ps2pdf it tries to optimize space and sometimes rotates the figures. There's a whole story about how dvi includes figures as links to files and how dvips,ps2pdf plant this file inside the document. Bottom line is - we don't like automatic orientation of figures. Once we got it right, we want it to behave the same even if the document has changed.

So… to disable automatic rotation in ps2pdf (the source for this tip is over here ):

1: ps2pdf -dAutoRotatePages=/None

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments

LaTeX - please don't mix bibliography and figures

| categories: latex | View Comments

The weird mingling of figs and bibliography which is the default setting in LaTeX could be avoided by using the package "placeins" . You could use several more barriers to make sure that all figures will not leak beyond certain position in text (for example - the end of a section).

1: \usepackage{placeins} % in the header
2: ....
3: \FloatBarrier % this forces all figures to be presented before the bibl.
4: \bibliographystyle{unsrt}
5: \bibliography{gyre_ref} % your bibtex file is probably named differently

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments

« Previous Page -- Next Page »