Follow-up to pgfplots: multiple loops for ticks, positioning, etc (and Passing a macro to an environment option (TikZ/pgfplots)), but there may be a LateX-only solution. I suppose there is a trivial solution with a loop in Lua, but I would prefer something that compiles with PdfLateX.
See the first linked question for working code, but the relevant snippet I would like to make work is:
\newcommand{\myxlist}{1,2,3,5} % The list of values should be hardcoded only once
\newcommand{\myylist}{\dosomethingon\myxlist} % <--- how to do this?
\begin{axis}
[xtick/.expanded=\myxlist,
ytick/.expanded=\myylist, % desired result: ytick={f(x1),f(x2)..f(xn)}
...]
\addplot[...]{sqrt(x)}; % not the actual f, but almost
\end{axis}
In English:
I want to plot a (simple) function f(x) and have ticks for a few given points on the function, based on the x-positions x1,x2...xn, and I want pgf to calculate the corresponding values of f on those points to make the y-ticks.
I can retype the function multiple times in the source code, it will not change and there is little risk of error. However I want to try different x1,x2,...xn lists, and I wish not to have to pre-compute them each time I change my mind about which one will be used.
EDIT: full document per request:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\newcommand{\myxlist}{1,2,3,5}
\begin{axis}[
xmin=0,xmax=10,
ymin=0,ymax=4,
xtick/.expanded=\myxlist,
ytick={1,1.4142136,1.7320508,2.236068} % how to compute this?
]
\addplot+[domain=0:10,samples=100,no markers]{sqrt(x)};
\end{axis}
\end{tikzpicture}
\end{document}

