Editing an Xfig .fig File

As I’m completing my doctoral dissertation, I needed to edit large numbers of encapsulated postscript images (.eps) to all have identical axis labeling, legends, etc. I also needed image scalability. So I wanted to use Xfig. I first converted my .eps images to Xfig .fig figures using

pstoedit -f xfig imagename.eps imagename.fig

The pstoedit command is wonderful and I highly recommend it. Then I loaded the images in Xfig, but needed to do lots of text resizing. This takes forever with point-and-click in Xfig. So I explored the .fig file.

Editing an Xfig .fig File

If I open a new file (say trial1.fig) and just start a textbox with 12-point Times-Roman font, I get a corresponding entry in the .fig file

#FIG 3.2 Produced by xfig version 3.2.5
1200 2
4 0 0 50 -1 0 12 0.0000 4 135 1050 1050 2475 This is a test.01

If I start changing things, I can see which items in the last row make changes.

Editing an Xfig .fig file.

  1. I can change the text alignment within the textbox. I can choose left, center, or right aligned by either changing the integer in the second column from 0 (left) to 1 or 2 (center, or right).
  2. The third integer in the row specifies fontcolor. For instance, 0 is black, but blue is 1 and Green3 is 13.
  3. The sixth integer in the bottom row specifies fontface. 0 is Times-Roman, but 16 is Helvetica (a MATLAB default).
  4. The seventh number is fontsize. 12 represents a 12pt fontsize. Changing the fontsize of an item really is as easy as changing that number to 20.
  5. The next number is the counter-clockwise angle of the text. Notice that I have changed the angle to .7854 (pi/4 rounded to four digits=45 degrees).
  6. The twelfth number is the position according to the standard “x-axis” in Xfig units from the left. Note that 1200 Xfig units is equivalent to once inch.
  7. The thirteenth number is the “y-position” from the top using the same unit convention as before.
  8. The nested text string is what you entered into the textbox.
  9. The “01” present at the end of that line in the .fig file is the closing tag. For instance, a change to 100 appends a @ symbol at the end of the period of that sentence.


I’ll try to do something similar to this for shapes, such as boxes.

Leave a Reply