1

I am plotting a graph on tikz and the labels for each coordinate (the reference in this case) are overlapping as the points are close together. Is there a way for me to define what anchor position each label gets for each point?

Thanks!

\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}

Current result of code.

Qrrbrbirlbel
  • 119,821

1 Answers1

2

Mixing together several answers here, like this one and this one --- I use a scatter plot; I added the class to change the color of the points just to identify them, and then added the anchor depending on a column in the table. You have to change that manually --- this is the anchor point range of the label; 0 means that the label will be on the left, -90 above, and so on.

I haven't the references, so all is [?] here; you probably need to manually adjust the label position when the real numbers go in.

\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}

I reformatted everything a bit, used scientific notation (I got lost with the number of zeroes ), and used siunitx for the units.

enter image description here

Rmano
  • 40,848
  • 3
  • 64
  • 125