font format in second y-axis

5 ビュー (過去 30 日間)
Yub3r
Yub3r 2017 年 3 月 29 日
移動済み: Walter Roberson 2023 年 11 月 18 日
Hello,
how can I change the font-style of the numbers of my second y-axis? For the first it is no problem for me. I want the font LaTeX.
I have following matlab-code:
if true
figure;
hold on;
grid on;
[ax, h1, h2] = plotyy(t, y1, t, y2);
set(gca, 'FontName', 'Times New Roman');
set(get(gca, 'xlabel'), 'interpreter', 'latex');
set(get(gca, 'xlabel'), 'FontName', 'latex');
set(get(gca, 'ylabel'), 'interpreter', 'latex');
set(get(gca, 'ylabel'), 'FontName', 'latex');
set(legend(), 'interpreter', 'latex');
set(legend(), 'FontName', 'latex');
set(gcf, 'WindowStyle', 'normal');
set(get(gca, 'ylabel'), 'interpreter', 'latex');
set(get(gca, 'ylabel'), 'FontName', 'latex');
set(ax(2), 'FontName', 'latex');
set(ax,{'ycolor'},{'k';'k'})
set(gca,'ytick',[-100:10:100])
set(ax(2),'YTick',[-100:20:100])
end
Thank you!
  2 件のコメント
Yub3r
Yub3r 2017 年 3 月 30 日
移動済み: Walter Roberson 2023 年 11 月 18 日
Can someone help?
Kenneth Harp
Kenneth Harp 2017 年 4 月 7 日
移動済み: Walter Roberson 2023 年 11 月 18 日
I have the same query....

サインインしてコメントする。

回答 (2 件)

Chibuzo Nnonyelu
Chibuzo Nnonyelu 2018 年 1 月 27 日
To label the axis in LaTeX font or style, use
set(gca, 'DefaultTextInterpreter', 'Latex');
This makes all LaTeX the default interpreter for all the axes.

Thomas Ferriday
Thomas Ferriday 2023 年 11 月 18 日
Use the function yyaxis instead of the plotyy. I achieved dual y-axes with latex formatting as such
x = linspace(1,10,100);
h = figure;
plot(x,sin(x),'k','LineWidth',2)
hold on
grid
yyaxis left
axesH = gca;
axesH.XAxis(1).TickLabelInterpreter = 'Latex';
axesH.XAxis(1).TickLabelFormat = '\\textbf{%g}';
axesH.YAxis(1).TickLabelInterpreter = 'Latex';
axesH.YAxis(1).TickLabelFormat = '\\textbf{%g}';
yyaxis right
axesH.YAxis(2).TickLabelInterpreter = 'Latex';
axesH.YAxis(2).TickLabelFormat = '\\textbf{%g}';
axesH.YColor = 'b';
plot(x,cos(x),'b--','LineWidth',2)
Following the correct sequence is important here, otherwise the latex formatting will not carry over to the second y-axis.

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by