# Plotting function with unique symbols [closed]

I would like to plot a function which involves multiple symbols created using Unique. Consider the following simple example.

X = {Unique["x"]}
Plot[Evaluate[2 X[[1]]], {Evaluate[X[[1]]], 0, 1}]


Unfortunately, this results in an error Plot::write: "Tag Evaluate in Evaluate[X[[1]]] is Protected.".

Is there a way to plot using "dynamic" variables?

• Related, possible duplicate: (7756), (20718), (46751) Commented Feb 7, 2016 at 14:49
• @Mr.Wizard It seems to me the underlying problem is that Evaluate should be placed outside the list, Evaluate@{X[[1]], 0, 1}. This is the issue in many posts, such as (5235) and (47907), and is also explained in this answer. I couldn't find one in which the issue was specifically using Evaluate in the second argument to Plot. It's usually the first argument. Commented Feb 7, 2016 at 17:09
• @MichaelE2 Yes, those are good, perhaps better, originals. And I found another related question and added it to my comment above. This question seems headed toward closure as "in the documentation" at this point; hopefully the links are useful to Markus and others. Commented Feb 7, 2016 at 17:14
• Thank you very much for the links. Commented Feb 7, 2016 at 17:56

If you have a relatively recent version of Mathematica, you don't need to use Evaluate.
X = {Unique["x"]};

• Using X={Unique["x"]};Plot[Legended[2 X[[1]], X[[1]]], {X[[1]], 0, 1}] does not work. I need something that works for symbol lists. Commented Feb 7, 2016 at 13:45
• Sorry if my question was not clear. I fixed it. Basically, I am wondering how to plot a function which depends on "dynamic" variables created using Unique. Commented Feb 7, 2016 at 14:00
• With solves the problem. Thanks. Commented Feb 7, 2016 at 14:02