I am plotting a series of rather busy plots consisting of many (5..25) lines of experimental data using pgfplots 1.14 and TikZ 3.0.1a. These curves are often overlapping, coexist near x or y axis, and generally have non-uniform appearance. I want to annotate each curve once, so currently the following piece of code for nodes is used:










\begin{axis} [
  xlabel     = {pH},
  ylabel     = {\ch{V^V}, \%},
  axis lines = left,
  clip       = false,
  xmin = 0.5, xmax = 14,
  ymin = 0,   ymax = 105,
  xtick      = {1,2,...,13},
  ytick      = {0,10,...,100},
  width      = \textwidth,
  height     = 12cm,
  grid       = major,
  grid style = {dashed,gray!30},

\addplot [smooth,thick] table [x = pH, y = {[VO2]+}, col sep = comma] {plots/distr-V-O-01.csv} 
node[pos = 0.2, pin = {90:\ch{[VO2]^+}}, inner sep = 0pt]{};

\addplot [smooth,thick] table [x = pH, y = {[H3V10O28]3-}, col sep = comma] {plots/distr-V-O-01.csv} 
node[pos = 0.5, pin = {-90:\ch{[H3V10O28]^{3-}}}, inner sep = 0pt]{};

\addplot [smooth,thick] table [x = pH, y = {[H2V10O28]4-}, col sep = comma] {plots/distr-V-O-01.csv} 
node[pos = 0.7, pin = {120:\ch{[H2V10O28]^{4-}}}, inner sep = 0pt]{};

%%% And so on for each data series, there are about 25 entries on average



where \ch{A3B5O_x} is one of the chemical formulas corresponding to the data series. Figuring out the correct angle and node position every time (so that labels, lines and axis are not overlapping) is extremely tedious, and to me it seems there must be an easier way of labeling such data plots automatically, so that 3 parameters - pin length, pin angle and node position on the line - are correctly estimated automatically based on how occupied certain plot area is.

And yes, I really need pins, using nodes near coords or summarizing all data lines in a legend area clutter plots inevitably.

If you could suggest another tool for this job beyond pgfplots, which is XeLaTeX-friendly, please feel free to do so.

I'm not sure how to attach .csv file properly, so here are the first lines from data file:


There are about 1000 lines. Here is a cropped area of the approximate plot

  • Welcome to TeX.SX! A minimal example of code seems necessary to better understand the problem. – egreg Feb 13 '17 at 22:18
  • 1
    As far as I know there is no automated way to do it which takes care of that the label isn't overlapping something else. – Stefan Pinnow Feb 13 '17 at 23:28
  • 1
    But if you have 25 lines, all of them showing in the same style which overlap multiple times that is -- in my point of few -- a very bad visualization anyway. Good luck with this attempt. – Stefan Pinnow Feb 13 '17 at 23:29
  • 1
    One very minor unrelated comment: pgfplots is a separate package from pgf/TikZ, although it builds on that. It is TikZ that has 3.0.1a as the latest stable version, pgfplots has 1.14. – Torbjørn T. Feb 26 '17 at 9:25
  • 1
    You can place nodes as arbitrarily as pins though. I don't see the actual benefit of pins that woudn't be possible with nodes – percusse Feb 26 '17 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.