仅更改一个额外刻度标签的位置

仅更改一个额外刻度标签的位置

我的一个额外 y 标签遮住了正常的 y 标签。如果不移动第二个标签,我就无法更改样式。

在此处输入图片描述

\documentclass[a4paper, 12pt, fleqn]{report}
\usepackage[left=25mm,right=25mm,top=30mm,bottom=30mm]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\usepackage{pgfplots}
\pgfplotsset{width=0.95\textwidth,compat=1.13}
\newcommand{\vertLineFromPoint}[1]{
    \draw[dashed] 
        (#1) -- (#1|-{rel axis cs:0,0})
    }
\newcommand{\horLineFromPoint}[1]{
    \draw[dashed] 
        (#1) -- (#1-|{rel axis cs:0,0})
    }

 \begin{document}
 \begin{center}
    \begin{tikzpicture}
    \begin{semilogyaxis}[
        extra x ticks={173.819},
        extra x tick labels={$L_e$},
        extra y ticks={8.5,24.033},
        extra y tick labels={$P_c$,$F_{UTS}$},
        extra tick style={grid=none},
        xlabel={Length [mm]},
        ylabel={Load [kN]},
        xmin=0, xmax=300,
        ymax=1000,
        xtick={0,50,100,150,200,250,300},
        legend pos=north east]

        \addplot[color=blue, mark=square, thick]
            coordinates{
            (300,2.847)(225,4.416)(175,8.267)(125,16.402)(75,45.56)(50,102.51)(25,410.041)
            };

        \addplot[color=BurntOrange, mark=o, thick]
            coordinates{
            (300,2.438)(225,3.898)(175,5.603)(125,8.339)(75,12.261)(50,14.555)(25,16.29)
            };

        \addplot[color=Green, mark=x, thick]
            coordinates {
            (250,3.55)(200,5.4)(150,9.45)(100,13.9)(65,15.6)
            };


        \vertLineFromPoint{173.819,8.5};
        \horLineFromPoint{173.819,8.5};
        \horLineFromPoint{300,24.033};
    \end{semilogyaxis}
    \end{tikzpicture}
    \end{center}

\end{document}

答案1

这是一个笨拙的破解,但你可以$P_c$用以下内容进行替换\raisebox{-8mm}{$P_c$}

在此处输入图片描述

这是您修改后的 MWE:

\documentclass[a4paper, 12pt, fleqn]{report}
\usepackage[left=25mm,right=25mm,top=30mm,bottom=30mm]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\usepackage{pgfplots}
\pgfplotsset{width=0.95\textwidth,compat=1.13}
\newcommand{\vertLineFromPoint}[1]{
    \draw[dashed]
        (#1) -- (#1|-{rel axis cs:0,0})
    }
\newcommand{\horLineFromPoint}[1]{
    \draw[dashed]
        (#1) -- (#1-|{rel axis cs:0,0})
    }

 \begin{document}
 \begin{center}
    \begin{tikzpicture}
    \begin{semilogyaxis}[
        extra x ticks={173.819},
        extra x tick labels={$L_e$},
        extra y ticks={8.5,24.033},
        extra y tick labels={\raisebox{-8mm}{$P_c$},$F_{UTS}$},
        extra tick style={grid=none},
        xlabel={Length [mm]},
        ylabel={Load [kN]},
        xmin=0, xmax=300,
        ymax=1000,
        xtick={0,50,100,150,200,250,300},
        legend pos=north east]

        \addplot[color=blue, mark=square, thick]
            coordinates{
            (300,2.847)(225,4.416)(175,8.267)(125,16.402)(75,45.56)(50,102.51)(25,410.041)
            };

        \addplot[color=BurntOrange, mark=o, thick]
            coordinates{
            (300,2.438)(225,3.898)(175,5.603)(125,8.339)(75,12.261)(50,14.555)(25,16.29)
            };

        \addplot[color=Green, mark=x, thick]
            coordinates {
            (250,3.55)(200,5.4)(150,9.45)(100,13.9)(65,15.6)
            };


        \vertLineFromPoint{173.819,8.5};
        \horLineFromPoint{173.819,8.5};
        \horLineFromPoint{300,24.033};
    \end{semilogyaxis}
    \end{tikzpicture}
    \end{center}

\end{document}

相关内容