MathGroup Archive 2000

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

Search the Archive

RE: Bug in Package Graphics`Graphics` ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26376] RE: [mg26348] Bug in Package Graphics`Graphics` ?
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 16 Dec 2000 02:40:09 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Johannes,

Most of the Mathematica plot routines, especially those in
Graphics`Graphics` are what I like to call "set-piece plots". They are
pretty good and solve most peoples needs in a simple manner. However, they
are not totally adaptable and often break down if you have very particular
needs. This is often the case if you are trying to do a really nice piece of
graphics.

However, it is usually not too difficult to design your own routines and
build up your graphics from more primitive elements. Here is a method for
producing your truncated positive and negative bar charts with two special
routines which draw and outline the bars.

For a truncated positive bar chart:

Needs["Graphics`Colors`"]

drawpositivebar[value_, center_, width_, bottom_, color_] :=
  Module[{bar, xmin = center - width/2, xmax = center + width/2},
    {color,
      bar = Polygon[{{xmin, bottom}, {xmax, bottom}, {xmax, value}, {xmin,
              value}, {xmin, bottom}}], GrayLevel[0], Line @@ bar}]

Show[Graphics[{MapThread[drawpositivebar[#2, #1, 0.8, 3,
        Red] & , {{1, 2, 3, 4}, {4, 10, 5, 7}}]}],
   AspectRatio -> Automatic, PlotRange ->
    {{0, 5}, {2.99, 10}}, Background -> Linen,
   Frame -> True, FrameTicks -> {Range[4], Automatic, None,
     Automatic}, PlotLabel ->
    "Truncated Positive\n     Bar Chart"];

For a truncated negative bar chart:

drawnegativebar[value_, center_, width_, top_, color_] :=
  Module[{bar, xmin = center - width/2, xmax = center + width/2},
    {color,
      bar = Polygon[{{xmin, top}, {xmax, top}, {xmax, value}, {xmin,
              value}, {xmin, top}}], GrayLevel[0], Line @@ bar}]

Show[Graphics[{MapThread[drawpositivebar[#2, #1, 0.8, -3,
        Red] & , {{1, 2, 3, 4}, {-4, -10, -5, -7}}]}],
   AspectRatio -> Automatic, PlotRange ->
    {{0, 5}, {-10.01, -3}}, Background -> Linen,
   Frame -> True, FrameTicks -> {None, Automatic, Range[4],
     Automatic}, PlotLabel ->
    "Truncated Negative\n     Bar Chart"];

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

> From: Ludsteck [mailto:Ludsteck at zew.de]
To: mathgroup at smc.vnet.net
> Dear Mathgroup members,
> I am very cautious in claiming to have found a bug in Mathematica, but
> here I am almost sure.
> After loading the package
> <<Graphics`Graphics`
>
> I tried to plot a simple BarChart:
>
> BarChart[{4,10,5,7}]
>
> However, if I want to restrict the plot range
>
> BarChart[{4,10,5,7}, PlotRange->{3,10}]
>
> Mathematica does not respond with an error message, but
> still plots in the range {0,10}. (However, the y-axis is not visible in
> {0,3}.)
> Furthermore, bar edges are visible only in the range {3,10}.
> Finally, if the input list contains negative values, the bars hide the
> BarLabels
> which is desastrous in my application.
>
> I am really an adherent of Mathematica, but if I am right here I have to
> state that it is not possible to create publication quality
> BarCharts with
> Mathematica. (At least not with the
> Add-On function BarChart.)
>
> Any suggestions?
>
>
>
> Johannes Ludsteck
> Forschungsbereich Arbeitsmaerkte,
> Personalmanagement und Soziale Sicherung
> Zentrum fuer europaeische Wirtschaftsforschung
> Mannheim (ZEW)
> Postfach 103443
> D 68934 Mannheim
>
> E-mail: ludsteck at zew.de
>
>



  • Prev by Date: Re: Second Opinion
  • Next by Date: Re: Second Opinion
  • Previous by thread: Re: Bug in Package Graphics`Graphics` ?
  • Next by thread: Second Opinion