Mathematica problem regarding plotting many functions in one graph

In summary, the conversation involves a problem with plotting multiple graphs in one plot using Mathematica. The x-axis of the plot needs to be in a log scale, so the loglinear command is used. The plot is b[a] vs. a, where w[a] is part of a differential equation that depends on a and c. The program is written for c = 1, but the user wants to plot for other c values (such as 1/3, 1/2, and 2/3) in the same plot. The question is if this is possible with Mathematica.
  • #1
kptsilva
33
0
hey guys i have a problem regarding plotting several graphs in one plot via mathematica. I want this plot's x-axis to be in a log scale so i used loglinear command.

here the plot is b[a] vs. a.
w[a] is part of my differential equation and it depends upon a and c.
i have written the program the program for c=1 below. I want to plot for several other c values(like c=1/3,1/2 and 2/3) in the same plot. is it possible via mathematica?

c = 1;
w[a_] := 2*a^(3*(1 + c))/(1 + 2*a^(3*(1 + c)));

fun = 2/3 a^2 b''[a] + (1 - w[a]) a b'[
a] - (1 + w[a]) (1 - 3 c w[a]) b[a]
test = NDSolve[{fun == 0, b'[10^(-4)] == 0, b[10^(-4)] == 1},
b, {a, 10^-4, 10}]
LogLinearPlot[Evaluate[b[a] /. test], {a, 10^-4, 10},
PlotRange -> All]
 
Physics news on Phys.org
  • #2
any help would be much appreciated
 

1. How do I plot multiple functions in one graph using Mathematica?

To plot multiple functions in one graph using Mathematica, you can use the Plot function and specify all the functions you want to plot within a list. For example: Plot[{Sin[x], Cos[x], Tan[x]}, {x, 0, 2Pi}] will plot the sine, cosine, and tangent functions on the same graph.

2. Can I change the color and style of each function in the plot?

Yes, you can specify the style of each function by using a list of directives as the second argument in the Plot function. For example: Plot[{Sin[x], Cos[x], Tan[x]}, {x, 0, 2Pi}, {Red, Blue, Dashed}] will plot the functions in red, blue, and with a dashed line style, respectively.

3. How do I add a legend to the plot?

You can add a legend to the plot by using the PlotLegends option in the Plot function. For example: Plot[{Sin[x], Cos[x], Tan[x]}, {x, 0, 2Pi}, PlotLegends->{"Sin", "Cos", "Tan"}] will add a legend with the names of each function in the plot.

4. Is it possible to customize the axes and labels in the plot?

Yes, you can use the AxesLabel and AxesStyle options in the Plot function to customize the axes and labels. For example: Plot[{Sin[x], Cos[x], Tan[x]}, {x, 0, 2Pi}, AxesLabel->{"x", "y"}, AxesStyle->Directive[Black, Thick]] will add labels to the axes and change their style to black and thick.

5. Can I save the plot as an image or export it to a file?

Yes, you can save the plot as an image or export it to a file by using the Export function. For example: Export["myplot.png", Plot[{Sin[x], Cos[x], Tan[x]}, {x, 0, 2Pi}]] will save the plot as a PNG image in your current directory.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
248
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
876
  • Programming and Computer Science
Replies
2
Views
1K
Back
Top