Hi William,

Am 28.01.2012 17:47, schrieb William Henney:
> The only thing missing now is some way to take per-point values from a
> data column for the "/pgfplots/nodes near coords align" parameter
> ("above", "below", "left", etc).  That would help in avoiding
> collisions between the labels and would allow me to use a larger font
> size.  Is it at all possible?

Yes, it is - and it is rather simple as well: you can modify your data 
table such that it contains a further column 'align'.
Then, you tell pgfplots that the visualization depends on its data -- in 
the very same way as you included the 'lambda' column. Once your data 
table is modified, you can add the following two lines to make it happen:

     nodes near coords align=\ALIGN,
     visualization depends on={value\thisrow{align} \as \ALIGN},

Here, the 'value\thisrow{align} \as\ALIGN' means to take the expanded 
value of \thisrow{align} verbatim, i.e. without parsing it as a number. 
Without the key word 'value', it would have been parsed as number.

NOTE: you need to change you data table's column name for (M-O)/E : it 
should not contain white spaces (since the default column separator is 
white space).

Here is a complete example:

Cloudy    El    lambda    Model    Observed    Error    M/O    
(M-O)/E    align
NE_3    Ne3    3869    8.17686723274    10.80    1.4    0.76    -1.87    
below
S_II    S2    4070    10.4475816855    8.227    0.979    1.27    2.27    
above
S_II    S2    4078    2.99580775427    2.698    0.318    1.11    0.94    
auto
C__2    C2    4267    0.207606269471    0.191    0.051    1.09    
0.33    below
TOTL    O3    4363    2.37236800689    2.011    0.207    1.18    1.75    
auto
HE_1    He1    4471    4.65171605379    4.3    0.416    1.08    0.85    auto
FE_3    Fe3    4659    2.60331622015    0.338    0.042    7.70    
53.94    auto
FE_3    Fe3    4702    1.44123467401    0.198    0.052    7.28    
23.91    auto
FE_3    Fe3    4734    0.756129700232    0.117    0.036    6.46    
17.75    auto
FE_3    Fe3    4755    0.47606006097    0.069    0.028    6.90    
14.54    {anchor=south west}
H__1    H1    4861    100.0    100    7.2    1.00    0.00    auto
O__3    O3    4959    85.6877662453    80.94    5.91    1.06    0.80    auto
O__3    O3    5007    257.917681537    232.7    16.2    1.11    1.56    auto
N__2    N2    5755    8.17735206821    5.91    0.65    1.38    3.49    auto
HE_1    He1    5876    14.5187752486    14.48    1.35    1.00    0.03    
auto
O__1    O1    6300    5.4711813156    4.846    0.446    1.13    1.40    auto
S__3    S3    6312    5.1304323418    3.88    0.357    1.32    3.50    auto
H__1    H1    6563    280.747361832    286    21.5    0.98    -0.24    auto
N__2    N2    6584    33.6017794459    33.84    2.54    0.99    -0.09    
auto
HE_1    He1    6678    3.78215599287    3.514    0.316    1.08    
0.85    auto
S_II    S2    6731    0.637016569893    0.747    0.067    0.85    
-1.64    auto
AR_3    Ar3    7135    26.2075170797    17.01    1.48    1.54    6.21    
auto

Note that even the complicated choice {anchor=south west} is possible 
here. This should allow all freedom that you need.

\documentclass{article}
\usepackage{fullpage}
\usepackage{txfonts}
\usepackage{pgfplots}

\newcommand\Ion[2]{\ensuremath{\mathrm{#1\,\scriptstyle #2}}}
\newcounter{ionstage}
\newcommand{\ion}[2]{% replace the aastex version
   \setcounter{ionstage}{#2}%
   \Ion{#1}{\Roman{ionstage}}}

% \usepgfplotslibrary{external}
% \tikzset{external/force remake}
% \tikzexternalize

\pgfplotsset{
   compat=1.5.1, % most current version as of writing (27 Jan 2012)
   % compat=newest, % select to always use latest version (may cause 
minor appearance changes)
   width=\textwidth,
}
\begin{document}
\begin{tikzpicture}
   \begin{loglogaxis}[
     xlabel={Observed Intensity, \(100 \times 
I_{\lambda}/I(\mathrm{H}\beta)\)},
     ylabel={Model Intensity, \(100 \times 
I_{\lambda}/I(\mathrm{H}\beta)\)},
     log ticks with fixed point,
     legend columns=4,
     legend pos=north west,
     % transpose legend,
     ]
     \addplot [
     scatter/classes={
       H1={mark=*,brown},%
       He1={mark=*,green},%
       C2={mark=triangle*,black},%
       N2={mark=triangle*,cyan},%
       O1={mark=*,orange},%
       O3={mark=square*,orange},%
       Ne3={mark=square*,blue},%
       S2={mark=triangle*,red},%
       S3={mark=square*,red},%
       Ar3={mark=square*,magenta},%
       Fe3={mark=square*,yellow}%
     },
     only marks, scatter,
     scatter src=explicit symbolic,
     point meta=explicit symbolic,
     nodes near coords*={\tiny\pgfmathprintnumber[set thousands 
separator={}]\LAMBDA\,\AA},
     visualization depends on={\thisrow{lambda} \as \LAMBDA},
     nodes near coords align=\ALIGN,
     visualization depends on={value\thisrow{align} \as \ALIGN},
     error bars/x dir=both,
     error bars/x explicit,
     error bars/y dir=none,
     ] table [
     x=Observed,
     y=Model,
     x error=Error,
     meta=El
     ] {ratios-177341.dat};
     \addlegendentry{\ion{H}{1}}
     \addlegendentry{\ion{He}{1}}
     \addlegendentry{\ion{C}{2}}
     \addlegendentry{[\ion{N}{2}]}
     \addlegendentry{[\ion{O}{1}]}
     \addlegendentry{[\ion{O}{3}]}
     \addlegendentry{[\ion{Ne}{3}]}
     \addlegendentry{[\ion{S}{2}]}
     \addlegendentry{[\ion{S}{3}]}
     \addlegendentry{[\ion{Ar}{3}]}
     \addlegendentry{[\ion{Fe}{3}]}
     \label[Ne3]{marker:Ne3}
     \addplot [gray,domain=0.2:300] {x};
   \end{loglogaxis}
\end{tikzpicture}

The marker for [\ion{Ne}{3}] is \ref{marker:Ne3}

\end{document}


Best regards

Christian

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Pgfplots-features mailing list
Pgfplots-features@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgfplots-features

Reply via email to