Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Plotting in mathematica

  1. Apr 6, 2015 #1

    joshmccraney

    User Avatar
    Gold Member

    Hi PF!

    I am trying to plot several quadratics along with two numerical solutions to some ODE's. The command I entered for the two ODE's is

    Plot[{{Evaluate[y[x] /. t]}, {Evaluate[y[x] /. s]}}, {x, 0, 1.2},
    PlotRange -> All]

    where s and t have been previously defined.

    The plot for the quadratics is

    Plot[Table[-.35 (1 - x)^2 + (1 - a)/2 (1 - x), {a,
    Range[-1/5, 0, .06]}] // Evaluate, {x, 0, 1.2},
    PlotLegends -> mList]

    Both these commands give me plots, but I'd like them all to be on the same graph. Can someone please help?

    Thanks so much!
     
  2. jcsd
  3. Apr 7, 2015 #2

    e.bar.goum

    User Avatar
    Science Advisor
    Education Advisor

    You can just add them to your list.
    Code (Text):

    Plot[{{Evaluate[y[x] /. t]}, {Evaluate[y[x] /. s]},Table[-.35 (1 - x)^2 + (1 - a)/2 (1 - x), {a,Range[-1/5, 0, .06]}] // Evaluate}, {x, 0, 1.2},PlotRange-> All,PlotLegends -> mList]
     

    Or, if you want the quadratics to remain different colours, you can use "Show[]"


    Code (Text):


    a=Plot[{{Evaluate[y[x] /. t]}, {Evaluate[y[x] /. s]}}, {x, 0, 1.2},PlotRange -> All]
    b = Plot[Table[-.35 (1 - x)^2 + (1 - a)/2 (1 - x), {a, Range[-1/5, 0, .06]}] // Evaluate, {x, 0, 1.2},PlotLegends -> mList]
    Show[a,b]
     
     
  4. Apr 7, 2015 #3

    joshmccraney

    User Avatar
    Gold Member

    Thanks a ton! That's really helpful!
     
  5. Apr 8, 2015 #4

    joshmccraney

    User Avatar
    Gold Member

    Hey e.bar.goum, how would I label each curve (sorry I'm new to mathematica). Each quadratic is labeled but the other two curves are not.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Plotting in mathematica
  1. Mathematica Plot (Replies: 1)

  2. Mathematica plotting (Replies: 4)

  3. Mathematica plot (Replies: 1)

  4. Plot in mathematica (Replies: 2)

Loading...