2

I am using pgfplot to make a 2D plot with the nodes labelled. However, some of the text labels interfere with each other as they're too close. The default positioning of text labels in pgfplot seems to be above the node. Is it possible to position them beside the node?

This is what I have (had to make the y axis semilogy to increase the spacing between points)

enter image description here

Here's what I want it to be (pardon my poor photoshopping skills)

enter image description here

The pgfplot code I am using is as described here: Update reference labels in scatter plots

5
  • 1
    Please supply a MWE. It will greatly help others to recreate and test your problem/solution.
    – nickpapior
    Dec 17, 2013 at 20:20
  • 3
    nodes near coords align=right? Dec 17, 2013 at 20:21
  • Or every node near coord/.style={anchor=270}
    – nickpapior
    Dec 17, 2013 at 20:23
  • 1
    @iab: To adjust the position of each individual label, take a look at How to display labels on points of a tikz plot
    – Jake
    Dec 17, 2013 at 21:22
  • @Jake Thanks for link. It's actually what I used eventually (the second answer i.e. \node [] at). Offers very fine-grained control :-)
    – picasso
    Dec 18, 2013 at 1:31

1 Answer 1

5

I guess nodes near coords align=right does what you're after.

enter image description here

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
  width=6cm,xmax=0.4, % these were just for the example
  nodes near coords align=right
  ]
\addplot+[nodes near coords,only marks,
  point meta=explicit symbolic]
  table[meta=label] {
x y label
0.3 0.2 [1]
0.2 0.1 [2]
 };
\end{axis}
\end{tikzpicture}
\end{document}
3
  • 1
    Can this be done to individual nodes you suppose? (Different from my original question I know)
    – picasso
    Dec 17, 2013 at 20:27
  • @iab I don't know, to be honest. Dec 17, 2013 at 20:29
  • This works for me. You're awesome.
    – picasso
    Dec 17, 2013 at 20:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .