MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Adding coloured Polygon to a BarChart

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83996] Re: Adding coloured Polygon to a BarChart
  • From: "David Park" <djmpark at comcast.net>
  • Date: Thu, 6 Dec 2007 02:48:34 -0500 (EST)
  • References: <fj65e2$fnd$1@smc.vnet.net>

Your only problem was that you put an extra level of Graphics in the Epilog 
list. The following works:

BarChart[{1, 2, 3},
 Epilog -> {Style[Text["First", {1, 2}, {0, -1}], 12, Red,
    Bold], {Red,
    Polygon[{{1.25, 2}, {1.5, 2}, {1.5, 2.25}, {1.25, 2.25}}]}}]

But Epilog is a little inconvenient. If you want to add many things Epilog 
becomes the tail that wags the dog. And suppose you wanted to add a curve to 
the plot? With the Presentations package all elements are combined in one 
drawing statement. Here is a bar chart with a curve and your extra label and 
polygon.

Needs["Presentations`Master`"]

Draw2D[
 {BarChart[{1, 4, 9}] // DrawGraphics,
  Style[Text["First", {1, 2}, {0, -1}], 12, Red, Bold],
  Red,
  Polygon[{{1.25, 2}, {1.5, 2}, {1.5, 2.25}, {1.25, 2.25}}],
  Draw[x^2, {x, 0, 3.2}]},
 AspectRatio -> 1,
 Axes -> True, AxesOrigin -> {0, 0},
 Ticks -> {CustomTicks[Identity, {1, 3, 1, 1}], Automatic}]


-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


<tomfabtastic at hotmail.com> wrote in message 
news:fj65e2$fnd$1 at smc.vnet.net...
> Hi,
>
> The below chart successfully uses Epilog to include some text on the
> BarChart:
>
> Needs["BarCharts`"]
> barShape1 =
> BarChart[{1, 2, 3},
>  Epilog -> {Style[Text["First", {1, 2}, {0, -1}], 12, Red, Bold]}]
>
> However, I want to add a small Polygon to the graph. Again this works
> well as long as the Polygon is black:
>
> barShape2 =
> BarChart[{1, 2, 3},
>  Epilog -> {Style[Text["First", {1, 2}, {0, -1}], 12, Red, Bold],
>    Polygon[{{1.25, 2}, {1.5, 2}, {1.5, 2.25}, {1.25, 2.25}}]}]
>
> But I would like to make the Polygon a red colour. But the below does
> not work :
>
> barShape3 =
> BarChart[{1, 2, 3},
>  Epilog -> {Style[Text["First", {1, 2}, {0, -1}], 12, Red, Bold],
>    Graphics[{Red,
>      Polygon[{{1.25, 2}, {1.5, 2}, {1.5, 2.25}, {1.25, 2.25}}]}]}]
>
> Does anyone have a suggestion for adding a coloured Polygon to a
> BarChart ?
>
> Regards,
> Tom
> 



  • Prev by Date: Re: solution to undetermined linear equation
  • Next by Date: Re: Slider[] and Dynamic[] implementation details
  • Previous by thread: Re: Adding coloured Polygon to a BarChart
  • Next by thread: Re: Adding coloured Polygon to a BarChart