0
$\begingroup$

I've to make a single figure composed of several plot but I can't do it. Can anyone help me?
Thank you all

$\endgroup$
4
  • 1
    $\begingroup$ Have a look at GraphicsGrid. $\endgroup$ Mar 25, 2021 at 8:34
  • 1
    $\begingroup$ Or Show[plotone,plottwo], to have plotone and plottwo overlaid instead of side by side $\endgroup$
    – Adam
    Mar 25, 2021 at 9:37
  • $\begingroup$ PlotGrid is certainly the way to go. GraphicsGrid is LESS/NOT recommended. $\endgroup$
    – sunt05
    Mar 25, 2021 at 9:39
  • $\begingroup$ Done! thank you all $\endgroup$
    – Laria
    Mar 25, 2021 at 17:16

1 Answer 1

1
$\begingroup$

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!

$\endgroup$
3
  • 1
    $\begingroup$ When putting multiple functions in a single Plot you can use one or more ConditionalExpressions 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$
    – Bob Hanlon
    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$
    – alex
    Mar 25, 2021 at 16:18
  • $\begingroup$ Depends on what you are trying to show/emphasize. You will need to judge what is better. $\endgroup$
    – Bob Hanlon
    Mar 25, 2021 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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