Matlab2tikz, the tick labels of the x-axis in bold

20 vues (au cours des 30 derniers jours)
Johannes Stiller
Johannes Stiller le 15 Mai 2021
Hello everyone,
I'm creating matlab plots, of which i create .tikz files to use in Latex. I'm using Texmaker and the latest version of matlab2tikz (1.1.0). I'm creating plots with two y-axis and had to use plotyy because yyaxis doesn't work with matlab2tikz.
The tick labels aren't bold in the plots viewed in matlab. But when i add them in Latex all the sudden the tick labels on the x-axis appear bold. And only the ones on the x-axis. Can someone help me to change them back to normal text?
to create .tikz files i use the command:
matlab2tikz('filename','veriAilPwmDeg.tikz','externalData',true,'dataPath','Data','relativeDataPath','Abbildungen/Plots/Data','height','0.2\textheight','width','0.8\textwidth');
this is how it's displayed in the Latex Document:
for Latex im using these packages with matlab2tikz:
\usepackage{svg}
\usepackage{pgf}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows.meta}
\usepgfplotslibrary{patchplots}
\usepackage{grffile}
\usepackage{amsmath}
\pgfplotsset{/pgf/number format/use comma}
\pgfplotsset{/pgf/number format/set thousands separator={}}
my plotting code: (first time using plotyy)
figure(1)
[hAx,hLine1,hLine2] = plotyy(dataTime_s,pwm_ar_s,dataTime_f,deg_ar_f);
Lyax = hAx(1);
Ryax = hAx(2);
xlim(hAx(1), [106.4289 112.6248])
xlim(hAx(2), [106.4289 112.6248])
ylim1 = 1460; % Auflösung auf 10er Schritte
ylim2 = 1510;
set(Lyax,'ylim',[ylim1 ylim2],'ytick',ylim1:10:ylim2)
ylim1d = 0.0678.*ylim1-101.7;
ylim2d = 0.0678.*ylim2-101.7;
ylimdtck = abs(abs(0.0678.*1010-101.7)-abs(0.0678.*1000-101.7));
set(Ryax,'ylim',[ylim1d ylim2d], 'YTick',ylim1d:ylimdtck:ylim2d)
hLine1.LineStyle = '--';
hLine2.LineStyle = '-';
hLine1.Color = [1 140/255 0];
hLine2.Color = [93/255 133/255 195/255];
xlabel('Flugzeit [s]')
ylabel(hAx(1),'PWM Werte der Querruder')
ylabel(hAx(2),'Auslenkung der Querruder [°]')
legend('simulierte Daten','reale Daten')
grid on
set(hAx,{'ycolor'},{'k';'k'})

Réponse acceptée

dpb
dpb le 15 Mai 2021
[hAx,hLine1,hLine2] = plotyy(dataTime_s,pwm_ar_s,dataTime_f,deg_ar_f);
linkaxes(hAx,'x') % link the two x-axes so will stay in synch automagically
hAx(2).XTick=[]; % clear one of the x-axes to avoid any display jitters
%set(hAx,'FontWeight','normal') % above may be cause and may not need this...
set(hAx,{'ycolor'},{'k';'k'})
xlim(hAx, [106.4289 112.6248])
ylim1 = 1460; % Auflösung auf 10er Schritte
ylim2 = 1510;
set(hAx(1),'ylim',[ylim1 ylim2],'ytick',ylim1:10:ylim2)
ylim1d = 0.0678.*ylim1-101.7;
ylim2d = 0.0678.*ylim2-101.7;
ylimdtck = abs(abs(0.0678.*1010-101.7)-abs(0.0678.*1000-101.7));
set(hAx(2),'ylim',[ylim1d ylim2d], 'YTick',ylim1d:ylimdtck:ylim2d)
...
Above is more nearly what I'd use with plotyy.
Firstly, it links the two 'x' axes so they will stay synchronized if you do use zoom or other interactive features.
Secondly, and what MAY be the problem with the apparent "bolding" of the x-axes, it clears the 'XTick' property for the RH axes so those tick labels will not be drawn. It is occasionally observed that internal numerical rounding can cause enough "jitter" in the display positions that the x axis labels, when written independently by each axes don't quite line up and results in the appearance of a bolded font.
You can check to see if this might be the problem in your case by querying the 'FontWeight' property of the X-axis -- if it's still 'Normal', then that's the sign and simply turning off the tick marks/labels for the RH axes should eliminate the problem.
  1 commentaire
Johannes Stiller
Johannes Stiller le 16 Mai 2021
The linking of the two 'x' axes worked for me. Thank you very much for your help!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by