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.

The manipulate function in Mathematica allows the users to adjust the values of the parameters in a graphical way. How do I plot multiple functions in a same graph and also I can use manipulate at the same time?

Manipulate[
 Row[{
   Plot[f1(x+n)], {x, 
     0.0001, 1}, PlotRange -> {-10, 10}],
   Plot[f2(x+n)], {x, 
     0.0001, 1}, PlotRange -> {-10, 10}]}],
   {n, 1, 10}]

with give two independent plots with single curve in each. How should I do multiple curve in a same plot?

share|improve this question

migrated from stackoverflow.com Jul 16 at 15:49

This question came from our site for professional and enthusiast programmers.

2 Answers 2

Like this?

f1[x_] := x^2;
f2[x_] := x^4;
Manipulate[
 Plot[{f1[x + n], f2[x + n]}, {x, 0.0001, 1}, PlotRange->{-10, 10}],
 {n, 1, 10}]

The documentation for Plot shows an example of doing exactly this on the second line. Plot

share|improve this answer
    
and how to indicate which is which? –  user3222184 Jul 14 at 1:22
    
You could try adding ,PlotLegends->LineLegend["Expressions"] after your PlotRange, but I tend to see the more you have to fiddle with your plot to make it look like you think it must the more grief you will have. And I don't even try to help with that. –  Bill Jul 14 at 7:45

Using Bill's answer but adding Epilog[] for labeling, try

f1[x_] := x^2;
f2[x_] := x^4;
Manipulate[
 Plot[{f1[x + n], f2[x + n]}, {x, 0.0001, 1}, 
  PlotStyle -> {Red, Blue}, PlotRange -> {-10, 10}, Epilog -> {
    (Text[
      Style["f1", FontFamily -> "Times New Roman", FontSize -> 10, 
       Red], {.6, f1[n + .6] + .6}]),
    (Text[
      Style["f2", FontFamily -> "Times New Roman", FontSize -> 10, 
       Blue], {.6, f2[n + .6] + .6}])
    }], {n, 1, 10}]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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