我想在 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
我为额外的勾号提供了一个标签(您可能需要微调样式,例如使用
\small
或修改数字)我删除了地块上的标签,因为它是多余的
我减少了
inner sep
轴上单个刻度的量1.5pt
,可能需要进行微调
我想您可以从这里了解到。