Tuesday, March 11, 2008

Tryst with Xmgrace

Xmgrace is a great WYSIWYG 2D plotting software available with GNU/Linux. Unfortunately it does not support 3D plotting at the moment. If you want to produce good quality graphs for technical papers, you should try your hands at it.

Typesetting

Grace permits quite complex typesetting on a per string basis. Any string displayed (titles, legends, tick marks,...) may contain special control codes to display subscripts, change fonts within the string etc.


Example:

F\sX\N(\xe\f{}) = sin(\xe\f{})\#{b7}e\S-X\N\#{b7}cos(\xe\f{})

prints roughly

                       -x
F (e) = sin(e)·e ·cos(e)
x

using string's initial font and e prints as epsilon from the Symbol font.

NOTE: Characters from the upper half of the char table can be entered directly from the keyboard, using appropriate xmodmap(1) settings, or with the help of the font tool ("Window/Font tool").


Control code
Description
\f{x} switch to font named "x", e.g. \f{Times}
\f{n} switch to font number n
\f{} return to original font
\R{x} switch to color named "x"
\R{n} switch to color number n
\R{} return to original color
\#{x} treat "x" (must be of even length) as list of hexadecimal char codes
\t{xx xy yx yy} apply transformation matrix
\t{} reset transformation matrix
\z{x} zoom x times
\z{} return to original zoom
\r{x} rotate by x degrees
\l{x} slant by factor x
\v{x} shift vertically by x
\v{} return to unshifted baseline
\V{x} shift baseline by x
\V{} reset baseline
\h{x} horizontal shift by x
\n new line
\u begin underline
\U stop underline
\o begin overline
\O stop overline
\Fk enable kerning
\FK disable kerning
\Fl enable ligatures
\FL disable ligatures
\m{n} mark current position as n
\M{n} return to saved position n
\dl LtoR substring direction
\dr RtoL substring direction
\dL LtoR text advancing
\dR RtoL text advancing
\x switch to Symbol font (same as \f{Symbol})
\+ increase size (same as \z{1.19} ; 1.19 = sqrt(sqrt(2)))
\- decrease size (same as \z{0.84} ; 0.84 = 1/sqrt(sqrt(2)))
\s begin subscripting (same as \v{-0.4}\z{0.71})
\S begin superscripting (same as \v{0.6}\z{0.71})
\T{xx xy yx yy} same as \t{}\t{xx xy yx yy}
\Z{x} absolute zoom x times (same as \z{}\z{x})
\q make font oblique (same as \l{0.25})
\Q undo oblique (same as \l{-0.25})
\N return to normal style (same as \v{}\t{})
\\ print \
\n switch to font number n (0-9) (deprecated)
\c begin using upper 128 characters of set (deprecated)
\C stop using upper 128 characters of set (deprecated)

Putting Symbols into Axis labels:

If you need special characters or special formatting in your label, you can use grace escape sequences (the sequence will appear verbatim in the text field but will be rendered on the graph), see typesetting above. If you don't remember the mapping between alphabetic characters and the glyph you need in some specific fonts (mainly symbol and zapfdingbats), you can invoke the font tool from the text field by hitting CTRL-e. You can change fonts and select characters from there, they will be copied back in the text field when you press the "Accept" button. Beware of the position of the cursor as you enter text or change font in the font tool, the character or command will be inserted at this position, not at the end of the string!


Note that you should see \f{Symbol} in the Cstring field of font tool when you select a symbol. In case you don't, write down manually and then click on a symbol you wish to insert and then press 'Accept'.

overlaying graphs

  1. Begin by selecting Main:Edit/Overlay graphs to bring up the Overlay widget.
  2. Select the graph numbers with which we would like to deal. In this example, we will overlay graph 1 onto graph 0. At this point, only graph 0 is visible. We cannot see Graph 1 to select since it does not exist at this point. We need to create simply by pressing mouse button 3 in a graph list window and selecting create new.
  3. The overlay type is determined by what is common among the overlayed graphs. In our example, the x axis is common so we will select X-axes same, Y-axes different. This is important because we don't want to alter any axes of the Overlay graph which we set the same as the underlay graph. In this example, we don't want to alter the x-axis of graph 1.
  4. We are now ready to label the graph axes and read the data. One thing we must be careful to do is to always make sure that we are working on the intended graph. Seeing as the graphs are overlain, clicking within the frame is ambiguous as to what graph is selected. The rule is that in a region of overlay, clicking will cycle between the graphs. Hence, if graph 1 is selecting, clicking within the frame will toggle to graph 0.
  5. Making sure that graph 0 is active, bring up the Axis properties widget. Now set the y axis title to Gnus.
  6. Select graph 1 as active as set the title as Gnats. Notice how it overlaps the Gnus. We want to put this on the right side. From the axis label and bar tab, select label Properties/Side=Opposite.
  7. Label the x axis to label it. If graph 1 is the current graph, noticed how it is greyed out because only 1 x axis need be active. Select graph 0 and you should now be able to alter the axis label.
  8. You are ready to read in data. Just make sure the graph that is active when you read in the data (or create your set) is the one in which you intend it to go.

Saturday, March 8, 2008

Installing Matlab 7 on Fedora 7

I will just list common problems and their probable solutions.

Problem 1: The installer does not work.
http://www.mathworks.com/support/solutions/data/1-12E9FJ.html?solution=1-12E9FJ

libXp.so.6: cannot open shared object file: No such file or directory

You need to install "libXp-devel" package.

# yum install libXp-devel

Problem 2:
Why does MATLAB fail to launch on Linux machines with an error about Assertion `c->xlib.lock' failed

http://www.mathworks.com/support/solutions/data/1-54UIFE.html?solution=1-54UIFE



Problem 3: When launching matlab, you may get following error

error while loading shared libraries: /usr/local/matlab73/bin/glnx86/libmwlapack.so: cannot restore segment prot after reloc: Permission denied

There are two solutions - first, you disable SELINUX. The other solution is to allow the permission in SELinux administration itself.

Open the SELinux Administration GUI and set the following Memory Protection Boolean to true.

Allow all unconfirmed executables to use libraries
requiring text relocation that are not labeled texttrel_shlib_t
.

or run following command on console

# chcon -t texrel_shlib_t /usr/local/matlab2006b/bin/glnx86/*.so

Saturday, March 1, 2008

Microphone not working on Debian Etch

I use alsa driver for my sound card. Sound works perfectly. However, microphone did not work for me. I could finally got it working after little exercise. Here is what I did.

If you are using gnome, then open "gnome-volume-control".

$ gnome-volume-control &

Edit -> preference -> click on 'microphone' and 'capture'. Now make sure the microphone and capture switches are un-muted. Don't close this window and open gnome-sound-recorder.

$ gnome-sound-recorder &

Click on the record button and say something on the mic. You should be able to hear your voice once you play the recorded file. If everything goes well, then save the settings.

$ sudo alsactl store