I would like to use an array in a PGF axis environment. This array would have the parameters values of a function to be plotted. I tried writing the following code:
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
\def\a{{1,2}} %Array definition
\begin{tikzpicture}
\begin{axis}[]
\addplot [
domain=0:10,
samples=100,
color=blue,
]
{(\a[0])+(\a[1])*x}; %Function to plot
\end{axis}
\end{tikzpicture}
\end{document}
I got an error in Texmaker, that says the following:
! Package PGF Math Error: Sorry, an internal routine of the floating point unit
got an ill-formatted floating point number `0.0'. The unreadable part was near
'0.0'. (in '({1,2}[0])+({1,2}[1])*x').
It seems that the function environment doesn't allow the use of arrays. There are some tikz commands that accept it, as is the case of \filldraw (you may see this). Is there any way to do this still using arrays and the axis environment?
