I A Mathematica code to plot two functions on the same screen

  • I
  • Thread starter Thread starter hagopbul
  • Start date Start date
  • Tags Tags
    Mathematica Plot
AI Thread Summary
To plot two functions in Mathematica on the same screen, users can utilize the Plot function with multiple functions specified in a list. An example provided includes plotting Sin[x] and Cos[x] with distinct colors and labels. Alternatives like GraphicsRow and GraphicsColumn allow for side-by-side or stacked plots, respectively. Users without access to Mathematica can use Wolfram Cloud for similar functionality. The discussion emphasizes the importance of correctly defining the functions and understanding the plotting syntax.
hagopbul
Messages
397
Reaction score
45
TL;DR Summary
Trying to remember a Mathematica code
Hello :

Trying to remember a Mathematica code (plot)
If I want to plot two function on the same screen in the following way
F(x) = f( qi)/f(bn) which i = (0,...,n), n =(0,...,m)
For every value of i we plot F(x) for all the valuse of n for example F(x) = f(q0)/f(b(n=0,...,m) ),...etc
When I use the plot function it looks like it is ploting the function this way
F(x) = f(q(i =0,...,n))/f(b(n=0,...,m))

Best Regards
H
 
Physics news on Phys.org
So there's a couple of ways I found from searching the question:

1) Use GraphicsRow to plot them in separate plots side by side
2) Use GraphicsColumn to plot them in separate plots stacked on top of one another
3) Use Plot as shown in the example below:

[CODE lang="python" title="Mathematica plot of sin and cos from 0 to 2pi"](* Define the functions *)
f1[x_] := Sin[x]
f2[x_] := Cos[x]

(* Plot both functions on the same graph *)
Plot[{f1[x], f2[x]}, {x, 0, 2 Pi},
PlotStyle -> {Red, Blue},
PlotLegends -> {"Sin[x]", "Cos[x]"},
AxesLabel -> {"x", "y"},
GridLines -> Automatic,
PlotLabel -> "Plot of Sin[x] and Cos[x]"][/CODE]

Note: I don't have Mathematica so I couldn't test this example. Your mileage may vary.
 
jedishrfu said:
Note: I don't have Mathematica so I couldn't test this example. Your mileage may vary.
Here's what @jedishrfu's Mathematica example code evaluates to:

1741576332766.png
 

Attachments

  • 1741574012798.png
    1741574012798.png
    19 KB · Views: 33
Last edited:
Thanks
For not having mathematica there is wolfram cloud which is like online mathematica for free
 
hagopbul said:
Thanks
For not having mathematica there is wolfram cloud which is like online mathematica for free
Thank you @hagopbul . It wouldn't have helped me because I didn't know they generated similar output.
 
Consider an extremely long and perfectly calibrated scale. A car with a mass of 1000 kg is placed on it, and the scale registers this weight accurately. Now, suppose the car begins to move, reaching very high speeds. Neglecting air resistance and rolling friction, if the car attains, for example, a velocity of 500 km/h, will the scale still indicate a weight corresponding to 1000 kg, or will the measured value decrease as a result of the motion? In a second scenario, imagine a person with a...
Dear all, in an encounter of an infamous claim by Gerlich and Tscheuschner that the Greenhouse effect is inconsistent with the 2nd law of thermodynamics I came to a simple thought experiment which I wanted to share with you to check my understanding and brush up my knowledge. The thought experiment I tried to calculate through is as follows. I have a sphere (1) with radius ##r##, acting like a black body at a temperature of exactly ##T_1 = 500 K##. With Stefan-Boltzmann you can calculate...
Thread 'Griffith, Electrodynamics, 4th Edition, Example 4.8. (First part)'
I am reading the Griffith, Electrodynamics book, 4th edition, Example 4.8 and stuck at some statements. It's little bit confused. > Example 4.8. Suppose the entire region below the plane ##z=0## in Fig. 4.28 is filled with uniform linear dielectric material of susceptibility ##\chi_e##. Calculate the force on a point charge ##q## situated a distance ##d## above the origin. Solution : The surface bound charge on the ##xy## plane is of opposite sign to ##q##, so the force will be...

Similar threads

Replies
1
Views
2K
Replies
2
Views
2K
Replies
1
Views
2K
Replies
4
Views
1K
Replies
0
Views
410
Back
Top