更改轴标签 pgfplots 中数学表达式的字体属性

更改轴标签 pgfplots 中数学表达式的字体属性

我认为只需使用以下方法更改轴标签的字体就很简单:

ylabel={$\frac{Su}{\sigma_{pc}^{'}}$ x},
ylabel style={font=\Huge},

但是它不起作用,我真的不明白为什么。以下是示例代码:

\documentclass[border=5pt]{standalone}
\usepackage{tikz,pgf,pgfplots}              % To generate the plot from csv


\begin{document}

\begin{tikzpicture}%[dots/.style={circle,draw=blue,fill=blue, inner sep=-1pt}]

    \begin{axis}[
    % SIZE
    scale only axis, % scale axis to specified size, otherwise 
    width=6cm,
    height=6cm,%{},
    % AXIS
    grid,
    grid style={solid,gray!50},
    % TICKS
    xticklabel pos=right,
    % LABELS
    xlabel={$\gamma_{zr} [\%]$},
    x label style={above,font=\tiny},
    xlabel near ticks,
    ylabel={$\frac{Su}{\sigma_{pc}^{'}}$ x},
    ylabel style={font=\tiny},
    ylabel near ticks,
    % LEGEND
    legend style={at={(0.01,0.01)},anchor=south west,font=\scriptsize},
        legend columns=1,
        legend style={/tikz/column 3/.style={column sep=10pt}},
        legend cell align=left,
    ]


\addplot [solid, black, mark=none, mark options={orange,scale=1}]{x^2};                         


    \end{axis}

\end{tikzpicture}

\end{document}

答案1

xlabel near ticks并使用/ylabel near ticks覆盖所做的更改。交换顺序,它就可以正常工作了。xlabel styleylabel style

xlabel near ticks执行/pgfplots/every axis x label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},而xlabel style执行every axis x label/.append style={...}。因此,当您xlabel style首先拥有 时,您会将某些内容附加到 的现有定义中every axis x label,但随后 会被 完全重新定义xlabel near ticks,因此您会失去自定义。

(顺便说一句,tikz加载pgf,但是pgfplots加载tikz,因此明确加载所有三个并不是真正必要的。)

在此处输入图片描述

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}              % To generate the plot from csv


\begin{document}

\begin{tikzpicture}%[dots/.style={circle,draw=blue,fill=blue, inner sep=-1pt}]

    \begin{axis}[
    % SIZE
    scale only axis, % scale axis to specified size, otherwise 
    width=6cm,
    height=6cm,%{},
    % AXIS
    grid,
    grid style={solid,gray!50},
    % TICKS
    xticklabel pos=right,
    % LABELS
    xlabel={$\gamma_{zr} [\%]$},
    xlabel near ticks,
    x label style={above,font=\tiny},
    ylabel={$\frac{Su}{\sigma_{pc}^{'}}$ x},
    ylabel near ticks,
    ylabel style={font=\Huge},
    % LEGEND
    legend style={at={(0.01,0.01)},anchor=south west,font=\scriptsize},
        legend columns=1,
        legend style={/tikz/column 3/.style={column sep=10pt}},
        legend cell align=left,
    ]


\addplot [solid, black, mark=none, mark options={orange,scale=1}]{x^2};                         


    \end{axis}

\end{tikzpicture}

\end{document}

相关内容