# Different outputs with same inputs

**URL:** <https://community.wolfram.com/t/different-outputs-with-same-inputs/2964>\
**Category:** Questions\
**Tags:** mathematica, graphics-and-visualization\
**Created:** [August 14, 2014, 12:42am UTC](https://community.wolfram.com/t/different-outputs-with-same-inputs/2964 "2014-08-14T00:42:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghoem](https://avatars.discourse-cdn.com/v4/letter/g/fbc32d/32.png) [@ghoem](https://community.wolfram.com/u/ghoem)\
**Post date:** [August 14, 2014, 12:42am UTC](https://community.wolfram.com/t/different-outputs-with-same-inputs/2964/1 "2014-08-14T00:42:22Z")

</div>

Why if I plot

Plot[Table[a x, {a, 5}], {x, -3, 3}]

all the lines have same colour but if I separate in this way

Table[a x, {a, 5}];  
Plot[%, {x, -3, 3}]

the lines have different colour?

---

<div class="post-metadata">

**Author:** ![dreiss](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss/32/29094_2.png) [@dreiss](https://community.wolfram.com/u/dreiss)\
**Post date:** [August 14, 2014, 2:46am UTC](https://community.wolfram.com/t/different-outputs-with-same-inputs/2964/2 "2014-08-14T02:46:03Z")

</div>

This is because the plot function has the attribute HoldAll. Because of this, the Plot function cannot tell that the head of the first argument is a list since the Table is not evaluated and, hence, has the Head Table. Generally when plotting something that will evaluate to a list of functions you should override the HoldAll for the first argument in this way:

```
Plot[Evaluate[Table[a x, {a, 5}]], {x, -3, 3}]

```

This serves two purposes. One is the one I just mentioned. The other one–and more important one–is that the Plot will then not need to evaluate the Table for every point on the graphs. It will evaluate the Table once before plotting and then plot the separate functions. This can often lead to a very significant performance advantage, especially if the evaluate of the first argument to yield the list of functions is itself time consuming.

---

<div class="post-metadata">

**Author:** ![ghoem](https://avatars.discourse-cdn.com/v4/letter/g/fbc32d/32.png) [@ghoem](https://community.wolfram.com/u/ghoem)\
**Post date:** [August 16, 2014, 5:21pm UTC](https://community.wolfram.com/t/different-outputs-with-same-inputs/2964/3 "2014-08-16T17:21:46Z")

</div>

Thanks for your answer!!

Now the question is:

Why has the plot function the attribute HoldAll???

Thanks again 🙂
