Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Inside the environment axis I can specify some points with axis cs. Up to now I am only able to use specific coordinates like 1,1. But I want to know how to use a mathematical expression like ln(3),2.

Here is an example:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.4}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis equal image,
width=10cm,
axis lines=middle,
axis line style={-latex},
xtick=\empty,
ytick=\empty,
ymin=-2.5, ymax=2.5,
xmin=-3.4,xmax=3.3,
clip =false,
xlabel={$x$},ylabel={$y$},
every axis x label/.append style={anchor=north},
every axis y label/.append style={anchor=east},
]

\foreach \c in {-2,-1,-0.5,0.5,1,2}
  \addplot[domain=-3:3,samples=200,restrict y to domain=-2:2]{ln(\c*x)};

%ln(1*3)1,098612289
\node[anchor=west] at (axis cs:3,1.099) {$c=1$};
%\node[anchor=west] at (axis cs:3,ln(3)) {$c=1$};
\end{axis}
\end{tikzpicture}
\end{document}

At the moment I am using:

%ln(1*3)1,098612289
\node[anchor=west] at (axis cs:3,1.099) {$c=1$};

but I would prefer a more automatic way

\node[anchor=west] at (axis cs:3,ln(3)) {$c=1$};
share|improve this question
2  
For a quick fix, you can use \pgfmathparse{ln(3)} \node[anchor=west] at (axis cs:3,\pgfmathresult) {$c=1$};. –  percusse Jan 29 '12 at 11:20
add comment

1 Answer 1

up vote 6 down vote accepted

You can say

\pgfmathlog{3}\let\mylog\pgfmathresult
\node[anchor=west] at (axis cs:3,{\mylog}) {$c=1$};

Not exactly the same, but I guess that performing complex calculations when looking for coordinates is not easy.

share|improve this answer
    
I am sure the the internal algorithm is complex so I can live with a small "work around" ;-) –  Marco Daniel Jan 29 '12 at 11:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.