Sunday, March 2, 2008

Display several plots together in Mathematica

In Mathematica one can display several plots together using the following command. Let's first generate two plots, for example,
g1 = Plot[Sin[x], {x,0,2Pi}];
g2 = Plot[Cos[x], {x,0,2Pi}];

One can then choose to show these two plots in the same graph:
Show[g1,g2]

or display them in an array:
Show[GraphicsArray[{g1,g2}]]

It is generally a good idea to assign a variable to each plot so later it can be used without regenerating the plot.

No comments: