Re: How to sync plots?
- To: mathgroup at smc.vnet.net
- Subject: [mg90320] Re: How to sync plots?
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Sat, 5 Jul 2008 04:52:39 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <g4klh1$m8l$1@smc.vnet.net>
Aaron Fude wrote:
> I produce several plots that eventually go into a GraphicsGrid. Is
> there a simple way to make sure that their PlotRanges are all
> identical? For example, they could all be set to the broadest needed
> PlotRange.
The following function should be a good starter. We extract the plot
range specifications for each graph. Then we look for the min and max
values for the x- and y-axes. Finally we replace the plot range
specifications by the new one and thus for every graphs.
normalizeRange[glist_List] :=
Module[{prlist, xr, yr, newpr},
prlist =
Cases[glist, (PlotRange -> {x_, y_}) -> {x, y}, Infinity];
xr = prlist[[All, 1]];
yr = prlist[[All, 2]];
newpr = {{Min[xr], Max[xr]}, {Min[yr], Max[yr]}};
Replace[glist, (PlotRange -> {x_, y_}) -> PlotRange -> newpr,
Infinity]]
glist = Table[Plot[(x - 2 n)^n, {x, -2 n, 2 n}], {n, 4}]
GraphicsGrid[Partition[normalizeRange[glist], 2]]
Regards,
-- Jean-Marc