From: Michael A. Gilchrist on 8 Jul 2010 03:12 Hi, I've been working with the Histogram[] function and want to include a legend. According to Mathematica's mystical ways the option Legend does not work with Histogram[]. Instead one needs to use a ChartLegend which has a different syntax and only a few options for placement (Top, Bottom, Center). My question: "Is there an easy way to finely control the placement of a legend in Histogram[]?" I've spent a couple of hours messing aroudn with Legend[], Inset[], Show[], ShowLegend[] and Graphics[], but to no avail. Any insights or suggestions would be welcome. Thanks in advance. Mike
From: David Park on 8 Jul 2010 07:41 data1 = RandomReal[NormalDistribution[0, 1], 500]; data2 = RandomReal[NormalDistribution[3, 1/2], 500]; color1 = RGBColor[0.2472`, 0.24`, 0.6`]; color2 = RGBColor[0.6`, 0.24`, 0.4428931686004542`]; ShowLegend[ Histogram[{data1, data2}], {{{Directive[Opacity[.7, color1]], "data 1"}, {Directive[Opacity[.7, color2]], "data 2"}}, LegendPosition -> {-0.8, 0.3}, LegendSize -> {0.7, 0.2}, LegendTextOffset -> {-0.6, 0}, LegendSpacing -> 0.6}] And using Presentations, or Epilog, you could also construct your own custom legend by drawing small rectangles and text directly on the plot. David Park djmpark(a)comcast.net http://home.comcast.net/~djmpark/ From: Michael A. Gilchrist [mailto:mikeg(a)utk.edu] Hi, I've been working with the Histogram[] function and want to include a legend. According to Mathematica's mystical ways the option Legend does not work with Histogram[]. Instead one needs to use a ChartLegend which has a different syntax and only a few options for placement (Top, Bottom, Center). My question: "Is there an easy way to finely control the placement of a legend in Histogram[]?" I've spent a couple of hours messing aroudn with Legend[], Inset[], Show[], ShowLegend[] and Graphics[], but to no avail. Any insights or suggestions would be welcome. Thanks in advance. Mike
From: Michael A. Gilchrist on 8 Jul 2010 20:35 Hi David, Thanks, that's exactly what I was trying to do. I forgot that ShowLegend uses more {} than just Legend which prevented my previous attempts from working. Best, Mike On Thu, 8 Jul 2010, David Park wrote: > data1 = RandomReal[NormalDistribution[0, 1], 500]; > data2 = RandomReal[NormalDistribution[3, 1/2], 500]; > > color1 = RGBColor[0.2472`, 0.24`, 0.6`]; > color2 = RGBColor[0.6`, 0.24`, 0.4428931686004542`]; > > ShowLegend[ > Histogram[{data1, data2}], > {{{Directive[Opacity[.7, color1]], "data 1"}, > {Directive[Opacity[.7, color2]], "data 2"}}, > LegendPosition -> {-0.8, 0.3}, > LegendSize -> {0.7, 0.2}, > LegendTextOffset -> {-0.6, 0}, > LegendSpacing -> 0.6}] > > And using Presentations, or Epilog, you could also construct your own custom > legend by drawing small rectangles and text directly on the plot. > > > David Park > djmpark(a)comcast.net > http://home.comcast.net/~djmpark/ > > > > From: Michael A. Gilchrist [mailto:mikeg(a)utk.edu] > > Hi, > > I've been working with the Histogram[] function and want to include a > legend. > According to Mathematica's mystical ways the option Legend does not work > with > Histogram[]. Instead one needs to use a ChartLegend which has a different > syntax and only a few options for placement (Top, Bottom, Center). > > My question: "Is there an easy way to finely control the placement of a > legend > in Histogram[]?" > > I've spent a couple of hours messing aroudn with Legend[], Inset[], Show[], > ShowLegend[] and Graphics[], but to no avail. Any insights or suggestions > would be welcome. > > Thanks in advance. > > Mike > > >
|
Pages: 1 Prev: FittedModel object type Next: FindMinimum numerical constraint functions |