我对 tikz 图片的 y 轴刻度有问题。该图包含两个 y 轴,tikz 似乎无法正确处理。我已经找到了这个链接 (在 pgfplot 中对齐次级 y 轴上的刻度标签),但是 texstudio 在编译此解决方案时出现问题。
代码附后:
% This file was created by matlab2tikz.
%
%The latest updates can be retrieved from
% http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\definecolor{mycolor1}{rgb}{0.00000,0.36078,0.58824}%
\definecolor{mycolor2}{rgb}{0.63137,0.69412,0.10196}%
%
\begin{tikzpicture}[font=\sffamily]
\begin{axis}[%
width=0.45\textwidth,
scale only axis,
xmin=0,
xmax=1,
xtick={ 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
xlabel={geregelte Machzahl $Ma_\textrm{N,Control}~\left\lbrack-\right\rbrack$},
xmajorgrids,
separate axis lines,
every outer y axis line/.append style={mycolor1},
every y tick label/.append style={font=\color{mycolor1}},
ymin=-50,
ymax=50,
ytick={-50, -25, 0, 25, 50},
%ylabel={Druckverlust $\triangle p_t~\left\lbrack\textrm{Pa}\right\rbrack$},
ymajorgrids,
axis background/.style={fill=white}
]
\addplot [color=mycolor1,solid,line width=1.5pt,forget plot]
table[row sep=crcr]{%
0.05 0.577365307486616\\
0.1 -0.111634692511871\\
0.2 -1.53963469251175\\
0.3 -4.40663469252468\\
};
\addplot [color=mycolor1,solid,line width=1.0pt,forget plot]
plot [error bars/.cd, y dir = both, y explicit]
table[row sep=crcr, y error plus index=2, y error minus index=3]{%
0.05 0.577365307486616 2.02796281884957 2.02796281884957\\
0.1 -0.111634692511871 4.40885720562954 4.40885720562954\\
0.2 -1.53963469251175 10.948300604055 10.948300604055\\
0.3 -4.40663469252468 25.0851926876272 25.0851926876272\\
};
\end{axis}
\begin{axis}[%
width=0.45\textwidth,
scale only axis,
xmin=0,
xmax=1,
%xtick={ 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
every outer y axis line/.append style={mycolor2},
every y tick label/.append style={font=\color{mycolor2}},
ymin=-1,
ymax=1,
ytick pos=right,
ylabel near ticks,
ytick={ -1, -0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8, 1},
ylabel={Abweichung der Machzahl $\frac{Ma_\textrm{N,True}}{Ma_\textrm{N,Control}}-1~\left\lbrack\%\right\rbrack$},
axis x line*=bottom,
axis y line*=right
]
\addplot [color=mycolor2,dashdotted,line width=1.5pt,forget plot]
table[row sep=crcr]{%
0.05 -0.0108565892090073\\
0.1 0.0541724835735558\\
0.2 0.0503289313137145\\
0.3 0.0224146746901743\\
};
\end{axis}
\end{tikzpicture}%