Problem showing a column object beside a graph using GraphicsGrid
- To: mathgroup at smc.vnet.net
- Subject: [mg82451] Problem showing a column object beside a graph using GraphicsGrid
- From: tomfabtastic at hotmail.com
- Date: Sat, 20 Oct 2007 05:59:28 -0400 (EDT)
Hello,
I have constructed a graph and would like to put alongside the graph a
legend. Here is the graph :
(*Construct first graph*)
xtick = Transpose[{Range[5], {"Jun-06", "Sep-06", "Dec-06", "Mar-07",
"Jun-07"}}];
ytick = Transpose[{Range[0, 6, 1],
Map[StringJoin["$", ToString[#]] &, Range[0, 6, 1]]}];
firstg = ListPlot[{{3, 4, 5, 5, 6}, {1, 1, 1, 1, 1}} , Joined -> True,
PlotRange -> {{0.5, 5.5}, {0, 6}}, AxesOrigin -> {0.5, 0},
Filling -> {1 -> {Axis, Brown}, 2 -> {Axis, Yellow}},
GridLines -> {None, Range[0, 6, 1]}, Frame -> True,
FrameTicks -> {{ytick, None}, {xtick, None}}];
(*Construct second graph*)
secondg =
StackedBarChart[{2, 2, 4, 4, 5}, {0.5, 0.5, 0.5, 0.5, 0.5},
BarStyle -> {Blue, Black}];
(*Combine graphs*)
combin = Show[firstg, secondg, PlotLabel -> "Title Here",
Epilog -> {Style[Text["First", {1, 5}, {0, -1}], 12, Hue[0], Bold],
Style[Text["Second", {1, 4}, {0, -1}], 12, Hue[.6], Bold]}]
Here is the legend column I would like to put alongside the graph :
blkSquare = Graphics[Polygon[{{0.1, 0}, {.1, .1}, {0, .1}, {0, 0}}]];
bluSquare =
Graphics[{Blue, Polygon[{{0.1, 0}, {.1, .1}, {0, .1}, {0, 0}}]}];
brnSquare =
Graphics[{Brown, Polygon[{{0.1, 0}, {.1, .1}, {0, .1}, {0, 0}}]}];
ylwSquare =
Graphics[{Yellow, Polygon[{{0.1, 0}, {.1, .1}, {0, .1}, {0, 0}}]}];
legend1 =
Column[{Style["Series 1", 15],
GraphicsRow[{Style["First", 15], blkSquare}],
GraphicsRow[{Style["Second", 15], bluSquare}],
Style["Series 2", 15],
GraphicsRow[{Style["First", 15], brnSquare}],
GraphicsRow[{Style["Second", 15], ylwSquare}] }, Frame -> True]
The problem is when I try to show the graph and legend column
together :
GraphicsGrid[{{combin, legend1 }}, ImageSize -> 700]
As can be seen, GraphicsGrid gives both objecst the same ImageSize.
What I want is for the legend to be much narrower and fit against the
graph which is bigger.
Any suggestions ?
Regards,
Tom