views:

63

answers:

1

Dear all:

I want to visualize a function of the form x^n such that n=1,2,...,10. I want these values of n to be generated by a loop and then plot the function as Plot[{x^n},{x,0,100}] and store the plot in an array. Then I want all of these arrays to be displayed into single plot. I tried to do this using Show function but with not much useful results. Also if you can also tell me how to set different colour for all the combined plots and also display a Legend.

+5  A: 

Can you clarify a bit more what you want? Specifically, why didn't Show work for you?

Combining plots is what Show is intended for:

Show[Table[
  Plot[x^n, {x, 0, 100}, PlotStyle -> ColorData[1][n]], {n, 10}], 
 PlotRange -> {All, 10^14}]

(I specified a PlotRange here, since each of these plots has a different automatically chosen plot range.)

Plot can also directly plot multiple functions at once:

Plot[Evaluate[Table[x^n, {n, 10}]], {x, 0, 100}]

(In the first example I used ColorData to mimic the exact same colors as are automatically used in the second example... But you can use any colors you want, such as Hue[RandomReal[]].)

Andrew Moylan
Thanks. This is what I wanted. I am very new to Mathematica. So I do not know much of the things :) Thanks again.
sul4bh