Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

What is the simplest way of plotting across multiple variables?

eg: I would like to plot something like this:

Plot[{x^0,x^1,x^2,x^3,x^4,x^5,x^6}, {x, 0, 10}]

using a simple command like this:

Plot[x^n, {x, 0, 10}, {n, 0, 6}]

(I realise this is not syntactically correct, but hopefully it will serve to illustrate the point.)

share|improve this question

closed as off-topic by Artes, rm -rf Dec 22 '13 at 2:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – rm -rf
If this question can be reworded to fit the rules in the help center, please edit the question.

possible duplicate of How do I use Map for a function with two arguments? –  Artes Dec 21 '13 at 20:14
@Artes That's very similar, but I don't think it's quite a duplicate. That one specifically deals with a function while here I presume martin would rather not have to define a helper function. Nevertheless if the community wishes to close I will not overrule. –  Mr.Wizard Dec 21 '13 at 20:26
@Mr.Wizard I voted to close (and perhaps eventually remove) because it is in the docs for Plot under "Basic Examples". –  rm -rf Dec 22 '13 at 2:20
@rm-rf So I now see. Evaluated -> True however is not, and the code in the documentation does not localize Symbols correctly so I think it is helpful to keep visible a method that does. –  Mr.Wizard Dec 22 '13 at 5:05
@Mr.Wizard There are several answers with Evaluated -> True and a lot of them by you, where you point out the localization issue –  rm -rf Dec 22 '13 at 5:24

1 Answer 1

up vote 3 down vote accepted

Is this simple enough for you?

Plot[Table[x^n, {n, 0, 6}], {x, 0, 10}, Evaluated -> True]

enter image description here

This method preserves symbol localization such that if x and/or n are defined globally it will not fail.

share|improve this answer
Thank you! Very simple & easy to implement! :) –  martin Dec 21 '13 at 20:08
I will look up the Evaluated in the documentation now. –  martin Dec 21 '13 at 20:14
@martin Sorry, I should have said: it's not strictly documented. However it's been in the system for a long time so I think you can depend on it. There are many examples of use on this site if you search for "Evaluated". Please also see (1731) –  Mr.Wizard Dec 21 '13 at 20:18

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