Reputation: 428
In GNU Octave I would like to set the tics of a plot as fractions. So instead of 0.0078125 (which is equal to 1/128) I would like to write "\frac 1 128".
I tried already
set(gca,'xTickLabel',{'\frac 1 128'});
but it does not work. The text '\frac 1 128' is not interpreted as LaTeX code.
Upvotes: 2
Views: 2101
Reputation: 8091
latex
isn't implemented yet in GNU Octave. You can use a subset of TeX for Greek symbols and so on.
If you just want to have LaTex in the generated print (for publication), you can use for example the device epslatexstandalone
and render it afterwards with latex
:
close all
graphics_toolkit fltk
title ("for thyme:")
t = linspace (0, 2 * pi, 100);
plot (t, sin (t))
set (gca, "xtick", [0 0.5 1 1.5 2] * pi)
set (gca, "xticklabel", {'$0$', '$\frac{\pi}{2}$', '$\pi$', '$\frac{3\pi}{2}$', '$2\pi$'})
grid on
set(gca, "fontsize", 20);
print -depslatexstandalone thyme
## process generated files with pdflatex
system ("latex thyme.tex");
## dvi to ps
system ("dvips thyme.dvi");
## convert to png for stackoverflow
system ("gs -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r100x100 -dEPSCrop -sOutputFile=thyme.png thyme.ps")
Upvotes: 6