how to use fraction and symbols in yticklabel?
Show older comments
I want a plot to have units of \frac{e^2}{2\hbar} in stead of 1, 2, 3,...
But I can only insert the math symbols in an ordinary label and not in a yticklabel.
The plot should have an y-axis with the values 0, \frac{e^2}{2\hbar}, 2 \frac{e^2}{2\hbar}.
How do I use the yticklabel with math symbols?
figure
plot(xdata,ydata)
set(gca,'ytick',[0, 1, 2])
set(gca,'yticklabel',{'0','$$\frac{e^2}{2\hbar}$$','$$2 \frac{e^2}{2\hbar}$$','Interpreter','latex'},'FontSize',13)
title('The conductivity','Fontsize',15),
xlabel('Photon energy [eV]','Fontsize',13)
1 Comment
hamed shorakaei
on 6 Oct 2017
The following style is work for labeling. Please use it for your purpose.
ylabel('$\displaystyle\frac{e^2}{2\hbar}$','interpreter','latex')
Accepted Answer
More Answers (1)
dan halbersberg
on 30 Jan 2016
0 votes
There is a way but you need to use the 'TickLabelInterpreter' property. Here is an example:
figure()
a = axes;
plot(xdata,ydata);
set(gca,'YTick',[0, 1, 2]);
set(a,'TickLabelInterpreter','latex');
set(gca,'YTickLabel',{'0','$$\frac{\textrm{e^2}}{\textrm{2\hbar}}$$','$$2 \frac{\textrme^3}}{\textrm{2\hbar}}$$'});
ylabel('\bf{Y values}','fontsize',14);
xlabel('\bf{X}','fontsize',14);
1 Comment
Walter Roberson
on 30 Jan 2016
Note: YTickLabelInterpreter is new as of R2014b
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!