Octave: LaTeX tics

喜夏-厌秋 提交于 2019-12-10 11:18:52

问题


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.


回答1:


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")



来源:https://stackoverflow.com/questions/37654737/octave-latex-tics

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!