Using Xfig


P. Gorham, Physics 305, 3/14/2018

1. Introduction

Computational physics is both a process and a message, as we have learned. How you present your results is a reflection of how well you understand the problem your are studying, as well as the results you propose to solve it.

We have gnuplot for creating 2D and 3D graphs of data, but it is not so useful for drawing diagrams that may be required to describe the solution or its physical context. We all learned early on that many problems in physics are much easier to solve if you make an accurate drawing of the geometry of the problem, or a force diagram, or some other related aspect that is best represented pictorially.

 So we really need a tool for doing this in the computational physics context. There are a number of graphics editors we could use: Inkscape,  Corel Draw, Visio, Dia, GIMP, OpenOffice Draw, and even Powerpoint.

Inkscape
is perhaps the best of all of these, and it is also open-source, but has a rather steep learning curve, although it is highly recommended for more detailed vector-graphics manipulation. For simplicity in this class,  the open-source tool we will learn is called Xfig.

Xfig is an open-source program for generating and manipulating figures and pictures. If you have used a computer-aided design (CAD) program before, then Xfig will seem rather simple, certainly most CAD programs (which are usually commercial) are far more complex.

Xfig has compatibility with Windows through either Cygwin, or (if your  Cygwin has problems) with a program derived from Xfig, called  WinFIG, that was until recently supported as an open-source project.  Unfortunately, currently WinFIG is not open source anymore, and the downloaded version is limited in functionality. The fully functional version costs 30 Euros.


For Mac OSX, I highly recommend installing Xfig using Macports.

Xfig's homepage is at:
http://mcj.sourceforge.net


and for WinFIG the link is
http://winfig.com
but as noted above you will have to pay for full functionality. It may be worth it, I am not sure since I have not tried it.


2. Getting started


From a terminal window, type "xfig &" to start the program and put it in the background. If you have used drawing programs before this will be fairly similar. If not, then try out the user manual on the Xfig page linked above for reference, and just start playing with the different buttons, checking the manual if things go wrong. Most of the buttons on the upper left of the Xfig pane create drawing objects (lines, circles, etc.) while the stuff on the lower left allows you to copy, change, edit, flip, rotate, etc. objects you have already made.

Here is an example of what you might see if you opened one of the example files below (3dhouse):



  Various different collections of buttons on the bottom appear for different commands selected in the left pane. In particular, note the 'depth' option which allows you to create different "planes" to your drawing, giving you the ability to overlay things and have them cover each other up.  Fonts, grids, colors, and other things are changed along the bottom. On the upper right are indications of the layer status and the mouse button status, and along the top are the pull-down menus for file and preference changes.
 
  The native Xfig "save" format is indicated by a "fig" suffix, but Xfig can export into png, eps, or lots of other formats. It can also read in such formats and embed your graph into its own native format, then export it back as .eps or .png, though this can be a bit buggy at times. This allows you to modify already completed .eps or .png pictures, if you want to add labels or something similar.

  The best way to learn xfig is just to keep trying its features until you find those that work the way you want to create the plot you are looking for. Line drawings are straightforward, just decide if you want it to "snap" to a grid, or if you want to go freehand. Boxes, polygons, and other shapes are easy.

Text is easy, just choose your font and size (or use the defaults) along the bottom button set, then hit the "text" button on the upper left, click to set your cursor where you want in the drawing,  and start typing. Superscripts and subscripts are a bit more obscure: in text mode you need to use the " [cntrl][shift] ^" or " [cntrl][shift] _" keystroke sequences to jump into superscript or subscript mode. However, note that the super-/sub-scripts so generated are separate entities from their parent word or symbol, so you need to use the "glue into compound" button (lower left group, top-left button) to glue them together if you need to move them around.


To learn more about Xfig, here is a collection of example files (the .fig files are all human-readable) that create various kinds of drawings. Download some of them and load them up in Xfig.

gold.fig        how does this work??
greek.fig       good for figuring out the keyboard mapping for different (eg symbol) fonts
aircraft.fig
3dhouse.fig      check out all the layers. Try turning them off and on.
house_elev.fig
experiment.fig
ps-schematic.fig    you can even do electric circuits.

3. Have fun!