
Me gustaría crear un TikGráfico z donde se utiliza un vector de números para incluir una imagen. Quiero que la imagen se escale usando el valor actual, de modo que las imágenes más altas y-axis
sean más grandes que aquellas con valores bajos. De alguna manera siempre me sale el error"Unidad de medida ilegal (pt insertado)"al intentar utilizar mi variable en el argumento de ancho. Eso es lo que he hecho hasta ahora:
\begin{tikzpicture}
\foreach \y [count=\x] in {0.5, 0.7, 0.8, 0.9, 0.95, 1, 1.05, 1.07, 1.2, 1.205, 2, 3, 3.1, 5, 5.4, 5.8, 6.1, 6.15, 6.125, 6.4}
\node at(\x,\y) {\includegraphics[width=\y*0.2cm]{../figs/Potato.png}};
\end{tikzpicture}
Respuesta1
\includegraphics
A diferencia de pgf, no analiza los argumentos de sus claves, por lo que es necesario analizarlos.
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \y [count=\x] in {0.5, 0.7, 0.8, 0.9, 0.95, 1, 1.05, 1.07, 1.2, 1.205, 2, 3, 3.1, 5, 5.4, 5.8, 6.1, 6.15, 6.125, 6.4}
\node at(\x,\y) {\pgfmathparse{\y*0.2}\includegraphics[width=\pgfmathresult cm]{example-image-duck}};
\end{tikzpicture}
\end{document}
Por cierto, \x
y \y
también ser utilizado por la calc
biblioteca. Entonces yo personalmente tal vez usaría
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \Y [count=\X] in {0.5, 0.7, 0.8, 0.9, 0.95, 1, 1.05, 1.07, 1.2, 1.205, 2, 3, 3.1, 5, 5.4, 5.8, 6.1, 6.15, 6.125, 6.4}
\node at(\X,\Y) {\pgfmathparse{\Y*0.2}\includegraphics[width=\pgfmathresult cm]{example-image-duck}};
\end{tikzpicture}
\end{document}
para estar seguro si luego decido usarlo calc
en el bucle.
Respuesta2
Es posible avanzar los cálculos en foreach
bucle y evitar\pgfmathparse
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \y [count=\x, evaluate=\y as \width using \y*0.2] in {0.5, 0.7, 0.8, 0.9, 0.95, 1, 1.05, 1.07, 1.2, 1.205, 2, 3, 3.1, 5, 5.4, 5.8, 6.1, 6.15, 6.125, 6.4}
\node at(\x,\y) {\includegraphics[width=\width cm]{example-image}};
\end{tikzpicture}
\end{document}