Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Mathematical Symbols in Xfig and gnuplot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Lonely-Star
Tux's lil' helper
Tux's lil' helper


Joined: 12 Jul 2003
Posts: 82

PostPosted: Wed Apr 27, 2005 9:12 am    Post subject: Mathematical Symbols in Xfig and gnuplot Reply with quote

Hi everybody,
Studying physics I am starting to use Xfig and gnuplot.
Now I wonder How I can use symbols like omega or phi in the text in xfig or labels in gnuplot.
Any help?
Thanks!
Back to top
View user's profile Send private message
furanku
l33t
l33t


Joined: 08 May 2003
Posts: 905
Location: Hamburg, Germany

PostPosted: Wed Apr 27, 2005 2:40 pm    Post subject: Reply with quote

Hi!

The good old "make-my-graphs-pretty" question :lol:

You have several possibilties.

gnuplot

1) The enhanced postscript driver

Start gnuplot. Try
Code:
gnuplot> plot sin(x) title "{/Symbol F}(x)"


You will get a window with your graph labled verbose as "{/Symbol F}(x)". But now try
Code:
gnuplot> set term post enh
Terminal type set to 'postscript'
Options are 'landscape enhanced monochrome blacktext \
   dashed dashlength 1.0 linewidth 1.0 defaultplex \
   palfuncparam 2000,0.003 \
   butt "Helvetica" 14'
gnuplot> set output "test.ps"
gnuplot> plot sin(x) title "{/Symbol F}(x)
gnuplot> exit

View the resulting file "test.ps" in your favorite postscript viewer: Now you have a greek upper Phi as label. To learn more about the enhanced possibilities of the postscrip driver read the file "/usr/share/doc/gnuplot-4.0-r1/psdoc/ps_guide.ps" (or whatever gnuplot version you use).

Advantages: Easy to use, output file easy included in almost every document
Disadvantages: Limited possibilities, looks ugly, wrong fonts when included in other documents (esp. LaTeX)

2) The LaTeX drivers

I guess you want to include your graph in a LaTeX File (I hope you have learned LaTeX, if not do so, quickly, it's essential for all physical publications!)

Again several possibilities...
2a) The "latex" driver, which uses the pictex environment
Code:
gnuplot> set term latex
Options are '(document specific font)'
gnuplot> set output "test.tex"
gnuplot> plot sin(x) title "$\Phi(x)$"
gnuplot> exit

Now gnuplot produced a file "test.tex" which you can include in your LaTeX Document with
Code:

\input{test.tex}

Process your LaTeX Document and you'll see the graph labled with the TeX Fonts and all the glory you can use to typeset formulas in LaTeX: fractions, integrals, ... all you can do in LaTeX can be used.

Advantage: beautifull output, fonts fitting to the rest of your document
Disadvantage: more complicated to use, limited capabilities of the LaTeX picture environment

2b) Combined LaTeX and Postscript. Almost like 2a) but now the graph is in Postscript, just the lables are set by LaTeX:
Code:
gnuplot> set term pslatex
Terminal type set to 'pslatex'
Options are 'monochrome dashed rotate'
gnuplot> set output "test.tex"
gnuplot> plot sin(x) title "$\Phi (x)$"
gnuplot> exit

Now the file "test.tex" will contain postscript special to draw the graph, the label is still set by LaTeX. Use it in your LaTeX Document like before.

Advantage: almost unlimited graphics possibilities due to postscript
Disadvantage: usage of poststcript needs converting the whole document to postscript afterwards (but that's normal anway), pdflatex isn't able to process postscript (well, VTeX's version can, but it's not open source)

3) The fig driver

You export your graph in gnuplot into xfigs "fig" file format, which can be usefull if you want to add modify your graph afterward, for example add some text and arrows (which can be also done in gnuplot but is a pain in the ass...)
Code:
gnuplot> set term fig textspecial
Terminal type set to 'fig'
Options are 'monochrome small pointsmax 1000 landscape inches dashed textspecial fontsize 10 thickness 1 depth 10 version 3.2'
gnuplot> set output "test.fig"
gnuplot> plot sin(x) title "$\Phi (x)$"
gnuplot> exit

Open your file "test.fig" in xfig and go on as described below.

XFig

Xfig offers you, almost like gnuplot the possibility to add greek symbols as postscript fonts, and has also a "special flag" which is meant for using LaTeX code in your illustration, which is set in LaTeX later when compiling your document with latex.

4) The symbol postscript font

Click in xfig on the large "T" to get the text tool. Click on "Text font (Default)" in the lower right corner and select "Symbol (Greek)". Click somewhere in the image. Now you can type greek letters. Unlike in gnuplot they will appear on the screen. Export your file to postscript and you can use it in your documents like the files generated by gnuplot described in 1) above.

5) The special text flag
Note the option "textspecial" in the "set term fig textspecial" command in 3) above. This tells xfig that text set with this flag has a special meaning in some exported formats. You can set it manually in xfig with the button "Text flags" in the lower bar. Set "Special flag" to "Special" in the appearing dialog. Now click somewhere and type somthing like "$\int{-\infty}^\infty e^{-x^2} dx$. Now go to "File -> Export" and select one of "Latex picture" (which is like gnuplots "latex" terminal described above) or "Combined PS/LaTeX (both parts)" (which is like gnuplots "pslatex" driver, with the only exception that the LaTeX and Postscript code are stored in two separate files. Don't worry, you will just have to include the file ending with "_t" into your LaTeX document, this will automaticall include the other file).

[Edit:] It may necessary to set the "hidden" flag in newer versions of xfig to avoid getting both labels, the one set by xfig and the one from LaTeX on top of each other.

You will see that there is also an "Combined PDF/LaTeX (both parts)" export options which is usefull if you want to generate pdf files from your LaTeX sources directly using pdflatex, since that can't include postscript graphics. On the other hand you still can make a dvi file from your LaTeX sources and convert that to pdf using dvipdf, or convert your postscript files to pdf by epstopdf, or ...

You see there are a lot of possibilities, and I just mentioned the ones I used, and did a good job for me during my diploma thesis in physics, and still do.

Fell free to ask if you still have questions,
Frank


Last edited by furanku on Thu Feb 14, 2008 10:31 am; edited 2 times in total
Back to top
View user's profile Send private message
Lonely-Star
Tux's lil' helper
Tux's lil' helper


Joined: 12 Jul 2003
Posts: 82

PostPosted: Wed Apr 27, 2005 5:14 pm    Post subject: Reply with quote

Thanks a lot for your help!
(it worked)
Back to top
View user's profile Send private message
incognito
n00b
n00b


Joined: 15 Jan 2004
Posts: 3

PostPosted: Wed Apr 27, 2005 11:30 pm    Post subject: lurkers thank you Reply with quote

furanku,

Great post :D - hopefully the moderators would consider putting it in the Documents, Tips, and Tricks section.

incognito
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Thu Apr 28, 2005 1:11 am    Post subject: Reply with quote

There;s a script which does all that very nicely and automatically... google for "texfig"
Back to top
View user's profile Send private message
furanku
l33t
l33t


Joined: 08 May 2003
Posts: 905
Location: Hamburg, Germany

PostPosted: Thu Apr 28, 2005 8:29 am    Post subject: Reply with quote

Thanks, incognito, but I guess it's not gentoo related enough for the tips and trick section. But almost all of our new students in our workgroup come up with this question after a while, so I thought that's a nice occasion to write down what I learned about that and give them simply the URL ;) (I guess, at least I have to spellcheck it on the weekend, sorry, I'm not a native english speaker and wrote it in a hurry yesterday...)

adsmith, that's a nice little script. It includes your exported fig file in a skeleton LaTeX document and processes and previews that. For larger documents I prefer the method using a make file which does the neccessary conversions (I didn't mention that xfig comes with a seperate program called "fig2dev" which can do all the exports xfig can do on the commandline). That combined with the preview-latex (screenshot) mode (which displays all your math and graphics inline in the [x]emacs, it's now part of auctex), gives me the for my taste most effective document writing environment. But as far as I can see new users are more attracted by kile (a KDE TeX environment, screenshots) or lyx (screenshots), and in that case texfig is a good help to get the LaTeX labels in your figures right. Thanks for your tip!
Back to top
View user's profile Send private message
nixnut
Bodhisattva
Bodhisattva


Joined: 09 Apr 2004
Posts: 10974
Location: the dutch mountains

PostPosted: Thu Feb 14, 2008 7:59 pm    Post subject: Reply with quote

Moved from Other Things Gentoo to Documentation, Tips & Tricks.
Tip/trick, so moved here
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum