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$
  • $\begingroup$ Show @@ Table[plots[i], {i, 1, 10}] $\endgroup$ – Quantum_Oli May 30 '17 at 9:56
  • $\begingroup$ Show[Table[plots[i],{i,1,10}]] $\endgroup$ – andre314 May 30 '17 at 9:56
  • 2
    $\begingroup$ Use Show[Table...] instead of the loop. It will make the job. $\endgroup$ – Alexei Boulbitch May 30 '17 at 9:57
2
$\begingroup$

In:

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

Out:

Mathematica graphics

$\endgroup$
  • $\begingroup$ Consider ..Evaluate @ Table ... $\endgroup$ – Kuba May 30 '17 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$ – UnchartedWorks May 30 '17 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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