如何標記軸上的點?

如何標記軸上的點?

我想在 x 軸上標記一個點(0.5066,-5.4),我嘗試使用代碼\node[label={180:{($\varepsilon_{cor}$)}},circle,fill,inner sep=2pt] at (axis cs:0.5066,-5.4) {};它顯示標籤的上半部。如何在軸上標記一個點並將其置於軸下方(如刻度線),但不更改刻度線?

在此輸入影像描述

\begin{tikzpicture} 
    \pgfplotsset{width=10cm,}
        \begin{axis}[
            xlabel={$\varepsilon$ /\si{\volt}},
            ylabel={$\lg \vert I \vert$},
            axis lines = box,
            xmin=0.18, xmax=0.82,
            ymin=-5.4, ymax=-2.9,
            xtick={0.2,0.3,0.4,0.5,0.6,0.7,0.8},
            ytick={-5,-4.5,-4,-3.5,-3,-2.5,-2},
            ymajorgrids=true,
            grid style=dashed,]
        \addplot[
            color=black,
            mark=*, mark size=1.5,
            ]
            coordinates {
            (0.2208 ,-3.05061)
            (0.2809 ,-3.1549 )
            (0.3309 ,-3.26761)
            (0.3709 ,-3.38722)
            (0.4008 ,-3.49485)
            (0.4208 ,-3.58503)
            (0.4309 ,-3.63827)
            (0.4408 ,-3.69897)
            (0.4508 ,-3.76955)
            (0.4609 ,-3.85387)
            (0.4708 ,-3.95861)
            (0.4759 ,-4.04576)
            (0.4808 ,-4.09691)
            (0.4858 ,-4.22185)
            (0.4909 ,-4.30103)
            (0.4958 ,-4.52288)
            (0.4978 ,-4.52288)
            (0.4998 ,-4.69897)
            (0.5019 ,-5      )
            (0.5039 ,-5      )
            (0.5063 ,-5.41   )}; 
        \addplot[
            color=black,
            mark=*, mark size=1.5,
            ]
            coordinates {
            (0.5066 ,-5.41   )  
            (0.5101 ,-5      )  
            (0.5121 ,-5      )  
            (0.5141 ,-4.69897)  
            (0.5161 ,-4.69897)  
            (0.521  ,-4.39794)  
            (0.526  ,-4.30103)  
            (0.5311 ,-4.1549 )  
            (0.536  ,-4.09691)  
            (0.5411 ,-4      )  
            (0.5511 ,-3.88606)  
            (0.5611 ,-3.79588)  
            (0.5711 ,-3.72125)  
            (0.5811 ,-3.67778)  
            (0.5911 ,-3.61979)  
            (0.611  ,-3.52288)  
            (0.6412 ,-3.40894)  
            (0.6811 ,-3.30103)  
            (0.7311 ,-3.19382)  
            (0.7911 ,-3.09691)}; 
            \node[label={180:{($\varepsilon_{cor}$)}},circle,fill,inner sep=2pt] at (axis cs:0.5066,-5.4) {};
        \end{axis}
    \end{tikzpicture}

答案1

用於yshift移動標籤。帶有標籤的節點變為:

\node[label={[yshift=2ex]180:{($\varepsilon_{cor}$)}},circle,fill,inner sep=2pt] at (axis cs:0.5066,-5.4) {};

其餘部分保持原樣,結果是:

在此輸入影像描述

編輯

由於OP要求這樣做,我提供了另一個解決方案。若要將標籤放置在刻度線的右側,您應該指定label={[right,yshift...

我冒昧地手動對齊它

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{amsmath,amssymb}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture} 
    \pgfplotsset{width=10cm,}
        \begin{axis}[
            xlabel={$\varepsilon$ /\si{\volt}},
            ylabel={$\lg \vert I \vert$},
            axis lines = box,
            xmin=0.18, xmax=0.82,
            ymin=-5.4, ymax=-2.9,
            xtick={0.2,0.3,0.4,0.5,0.6,0.7,0.8},
            ytick={-5,-4.5,-4,-3.5,-3,-2.5,-2},
            ymajorgrids=true,
            grid style=dashed,]
        \addplot[
            color=black,
            mark=*, mark size=1.5,
            ]
            coordinates {
            (0.2208 ,-3.05061)
            (0.2809 ,-3.1549 )
            (0.3309 ,-3.26761)
            (0.3709 ,-3.38722)
            (0.4008 ,-3.49485)
            (0.4208 ,-3.58503)
            (0.4309 ,-3.63827)
            (0.4408 ,-3.69897)
            (0.4508 ,-3.76955)
            (0.4609 ,-3.85387)
            (0.4708 ,-3.95861)
            (0.4759 ,-4.04576)
            (0.4808 ,-4.09691)
            (0.4858 ,-4.22185)
            (0.4909 ,-4.30103)
            (0.4958 ,-4.52288)
            (0.4978 ,-4.52288)
            (0.4998 ,-4.69897)
            (0.5019 ,-5      )
            (0.5039 ,-5      )
            (0.5063 ,-5.41   )}; 
        \addplot[
            color=black,
            mark=*, mark size=1.5,
            ]
            coordinates {
            (0.5066 ,-5.41   )  
            (0.5101 ,-5      )  
            (0.5121 ,-5      )  
            (0.5141 ,-4.69897)  
            (0.5161 ,-4.69897)  
            (0.521  ,-4.39794)  
            (0.526  ,-4.30103)  
            (0.5311 ,-4.1549 )  
            (0.536  ,-4.09691)  
            (0.5411 ,-4      )  
            (0.5511 ,-3.88606)  
            (0.5611 ,-3.79588)  
            (0.5711 ,-3.72125)  
            (0.5811 ,-3.67778)  
            (0.5911 ,-3.61979)  
            (0.611  ,-3.52288)  
            (0.6412 ,-3.40894)  
            (0.6811 ,-3.30103)  
            (0.7311 ,-3.19382)  
            (0.7911 ,-3.09691)}; 
            \node[label={[right,yshift=2.1ex,xshift=0.3em]180:{($\varepsilon_{\mathrm{cor}})=0.5066$}},circle,fill,inner sep=2pt] at (axis cs:0.5066,-5.4) {};
        \end{axis}
    \end{tikzpicture}
   \end{document}

生產:

在此輸入影像描述

編輯2

我重新定位了軸上的標籤。

核心部分是:

extra x ticks={0.5066},
        extra x tick labels={$\varepsilon_{\mathrm{cor}} ({\scriptstyle 0.5066})$},

另外,我修正了軸刻度:

        \node[circle,fill,inner sep=1.5pt] at (axis cs:0.5066,-5.4) {};

代碼是:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{amsmath,amssymb}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture} 
    \pgfplotsset{width=10cm,}
        \begin{axis}[
            xlabel={$\varepsilon$ /\si{\volt}},
            ylabel={$\lg \vert I \vert$},
            axis lines = box,
            xmin=0.18, xmax=0.82,
            ymin=-5.4, ymax=-2.9,
            xtick={0.2,0.4,0.6,0.8},
            ytick={-5,-4,-3,-2},
            ymajorgrids=true,
            extra x ticks={0.5066},
            extra x tick labels={$\varepsilon_{\mathrm{cor}} ({\scriptstyle 0.5066})$},
            grid style=dashed,]
        \addplot[
            color=black,
            mark=*, mark size=1.5,
            ]
            coordinates {
            (0.2208 ,-3.05061)
            (0.2809 ,-3.1549 )
            (0.3309 ,-3.26761)
            (0.3709 ,-3.38722)
            (0.4008 ,-3.49485)
            (0.4208 ,-3.58503)
            (0.4309 ,-3.63827)
            (0.4408 ,-3.69897)
            (0.4508 ,-3.76955)
            (0.4609 ,-3.85387)
            (0.4708 ,-3.95861)
            (0.4759 ,-4.04576)
            (0.4808 ,-4.09691)
            (0.4858 ,-4.22185)
            (0.4909 ,-4.30103)
            (0.4958 ,-4.52288)
            (0.4978 ,-4.52288)
            (0.4998 ,-4.69897)
            (0.5019 ,-5      )
            (0.5039 ,-5      )
            (0.5063 ,-5.41   )}; 
        \addplot[
            color=black,
            mark=*, mark size=1.5,
            ]
            coordinates {
            (0.5066 ,-5.41   )  
            (0.5101 ,-5      )  
            (0.5121 ,-5      )  
            (0.5141 ,-4.69897)  
            (0.5161 ,-4.69897)  
            (0.521  ,-4.39794)  
            (0.526  ,-4.30103)  
            (0.5311 ,-4.1549 )  
            (0.536  ,-4.09691)  
            (0.5411 ,-4      )  
            (0.5511 ,-3.88606)  
            (0.5611 ,-3.79588)  
            (0.5711 ,-3.72125)  
            (0.5811 ,-3.67778)  
            (0.5911 ,-3.61979)  
            (0.611  ,-3.52288)  
            (0.6412 ,-3.40894)  
            (0.6811 ,-3.30103)  
            (0.7311 ,-3.19382)  
            (0.7911 ,-3.09691)}; 
                       \node[circle,fill,inner sep=1.5pt] at (axis cs:0.5066,-5.4) {};
        \end{axis}
    \end{tikzpicture}\end{document}

這是結果

在此輸入影像描述

基本上:

  • 我減少了兩個軸上的刻度(你可以按照你的意願做)

  • 我在 x 軸上提供了一個額外的勾號,其中extra x ticks

  • 我為額外的刻度提供了一個標籤(您可能需要微調樣式,例如使用 a\small或修改數字)

  • 我刪除了情節上的標籤,這是多餘的

  • 我將inner sep軸上的單個刻度減少到1.5pt,它可能需要微調

我想你可以從這裡接。

相關內容