views:

264

answers:

1

My school has Matlab but I can't use it at home so I am trying to learn Octave. I am having trouble saving plots as png files so I can put them in a report.

I read you can use print("filename.png") to save the plots, but I am getting some kind of error I am assuming is due to using latex in my labels

I am using xlabel('\omega')

Error message: gdImageStringFT: Could not find/open font while printing string w with font Symbol

The plot still saves, but any label with latex in it just doesn't print at all. I know I could just avoid formatting the text, but it just looks so much nicer with latex.

Anyone know what I can do? (ps I am not very advanced with linux just fyi)

+1  A: 

So what happens here is that for the png format Octave needs to have the Symbols font at its disposal if you want to include, e.g., greek letters. This is because png is a bitmap format and the letters are rasterized and printed into the picture.

The correct way, or at least the way most people circumvent Octave's / Mathematica's / etc. poor labeling, is to output encapsulated postscript (.eps) with dummy labels. These labels are kept separate in the eps format and one can then use the psfrag package in LaTeX to replace the dummy labels for correct labels. This allows for much better control over the label and gives you access to all of LaTeX's formatting and formulas.

Here or here is a hands on tutorial how to do this with Octave and gnuplot.

Timo