I've to make a single figure composed of several plot but I can't do it.
Can anyone help me?
Thank you all
1 Answer
I would suggest two methods:
Show[{
Plot[Cos[2 x], {x, 0, 4 \[Pi]}, PlotStyle -> Blue],
Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotStyle -> Red]
}]
or even more simply
Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}]
Note that when you use Show, you simply put plots together. The axes are automatically defaulting to the parameters of the first graph you have added. Here I created a plot that has a smaller range than the other to demonstrate the effect. Had you reversed the order in the Show, then you'd crop the second function.
Putting all your functions under the same plot simplifies some of that and automatically colours them for you, but the evaluation parameters for x {x,min,max} is common for all of them.
I hope that helps!
-
1$\begingroup$ When putting multiple functions in a single
Plot
you can use one or moreConditionalExpression
s to use different plot ranges, e.g.,Plot[{ConditionalExpression[Sin[x], 0 < x < 2 Pi], ConditionalExpression[Cos[x], Pi < x < 4 Pi]}, {x, 0, 4 Pi}]
$\endgroup$ Mar 25, 2021 at 13:52 -
$\begingroup$ That is a really good point! Thought to keep it simple to begin with. Is that generally better than simply having two plots with distinct ranges? $\endgroup$– alexMar 25, 2021 at 16:18
-
$\begingroup$ Depends on what you are trying to show/emphasize. You will need to judge what is better. $\endgroup$ Mar 25, 2021 at 17:21
GraphicsGrid
. $\endgroup$Show[plotone,plottwo]
, to haveplotone
andplottwo
overlaid instead of side by side $\endgroup$PlotGrid
is certainly the way to go.GraphicsGrid
is LESS/NOT recommended. $\endgroup$