0
$\begingroup$

Say I define a function to create plots

plots[i_]:=Plot[x^i,{x,0,1}]

And that I generate many plots in one output

Do[Print[plots[i]],{i,1,10}]

How can I combine the 10 plots I get using the function Show? (or anthing that works similarly)

$\endgroup$
3
  • $\begingroup$ Show @@ Table[plots[i], {i, 1, 10}] $\endgroup$ Commented May 30, 2017 at 9:56
  • $\begingroup$ Show[Table[plots[i],{i,1,10}]] $\endgroup$
    – andre314
    Commented May 30, 2017 at 9:56
  • 2
    $\begingroup$ Use Show[Table...] instead of the loop. It will make the job. $\endgroup$ Commented May 30, 2017 at 9:57

1 Answer 1

3
$\begingroup$

In:

plots[n_] := Plot[Table[x^i, {i, n}], {x, 0, 1}]
plots[8]

Out:

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ Consider ..Evaluate @ Table ... $\endgroup$
    – Kuba
    Commented May 30, 2017 at 12:52
  • $\begingroup$ Thanks! I forgot it. It reminded me that I have to use Evaluate @ Table sometimes. I have tried a couple of different functions, it seems that Evaluate is unnecessary in this case . f[x_] := Sin[x] + Cos[x]; plots[n_] := Plot[Table[f[i x], {i, n}], {x, 0, 1}]; plots[8] $\endgroup$
    – webcpu
    Commented May 30, 2017 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.