我在 tikz 上绘制图表,由于点靠得很近,每个坐标(本例中为参考)的标签重叠。有没有办法定义每个点的每个标签的锚点位置?
谢谢!
\begin{tikzpicture}
\begin{axis}[
grid,
xmode=log,
ymode=log,
xmin=0, xmax=1000,
ymin=1000, ymax=10000000000,
xlabel={Carrier Mobility/ cm$^2$(Vs)$^{-1}$},
ylabel={I$_{ON}$/I$_{OFF}$}
]
\addplot+ [every node near coord/.append style={font=\tiny,color=black}, nodes near coords, only marks, point meta=explicit symbolic]
table[meta=label]{
x y label
217 100000000 \cite{radisavljevic2011single}
11 100000 \cite{kang2014high}
36.4 1000000 \cite{wu2016high}
11.3 1000000 \cite{ahn2017ambient}
6 1000000000 \cite{amani2013electrical}
16.1 10000000 \cite{amani2013electrical}
80 10000 \cite{yu2016design}
17 100000000 \cite{wu2013high}
25 10000000 \cite{nourbakhsh2016mos2}
21 10000000 \cite{fang2018controlled}
12.24 1000000 \cite{choudhary2016synthesis}
16.1 100000000 \cite{hong2015exploring}
9.5 100000000 \cite{kumar2023optoelectronic}
10 10000000 \cite{liu2019ambipolar}
44.8 10000000 \cite{chen2018dramatic}
};
\end{axis}
\end{tikzpicture}
答案1
这里混合了几个答案,比如这个和这个--- 我使用散点图;我添加了类来更改点的颜色以便识别它们,然后根据表中的列添加锚点。您必须手动更改它 --- 这是标签的锚点范围;0
意味着标签将位于左侧、-90
上方等等。
我没有参考资料,所以所有内容都[?]
在这里;您可能需要在输入实际数字时手动调整标签位置。
\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
grid,
xmode=log,
ymode=log,
xmin=2, xmax=1000, %<---- you can't have "0" here for xmode=log
ymin=1000, ymax=1e10,
xlabel={Carrier Mobility (\unit{\cm\squared\per\volt\per\second})},
ylabel={I$_{\mathit{ON}}$/I$_{\mathit{OFF}}$} %<- it's the word OFF, not O multiplied F multiplied F...
]
\addplot [every node near coord/.append style={font=\tiny,color=black,
anchor=\Anchor},
scatter/classes={a={blue}, b={red}},
scatter, mark=*, only marks,
scatter src=explicit symbolic,
nodes near coords*={\Label},
visualization depends on={value \thisrow{label} \as \Label},
visualization depends on={value \thisrow{anchor} \as \Anchor},
]
table[meta=class]{
x y label class anchor
217 1e8 \cite{radisavljevic2011single} a -90
11 1e5 \cite{kang2014high} a -90
36.4 1e6 \cite{wu2016high} a -90
11.3 1e6 \cite{ahn2017ambient} a -90
6 1e9 \cite{amani2013electrical} a -90
16.1 1e7 \cite{amani2013electrical} a -90
80 1e4 \cite{yu2016design} a -90
17 1e8 \cite{wu2013high} b 180
25 1e7 \cite{nourbakhsh2016mos2} a -90
21 1e7 \cite{fang2018controlled} b 90
12.24 1e6 \cite{choudhary2016synthesis} b 180
16.1 1e8 \cite{hong2015exploring} a -90
9.5 1e8 \cite{kumar2023optoelectronic} a -90
10 1e7 \cite{liu2019ambipolar} a -90
44.8 1e7 \cite{chen2018dramatic} a -90
};
\end{axis}
\end{tikzpicture}
\end{document}
我重新格式化了所有内容,使用了科学计数法(我对零的数量感到困惑