MathGroup Archive 2000

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

Search the Archive

Re: BarChart Bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23621] Re: [mg23587] BarChart Bug?
  • From: BobHanlon at aol.com
  • Date: Wed, 24 May 2000 02:16:22 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 5/21/2000 6:23:10 PM, cBLZ at hhs.se writes:

>I want to display probabilities and cumulative probabilities for a discrete
>random variable (integer valued) in the same bar chart.
>
>In 'My example' (see below), the height of the vertical axis gets chopped
>at .35, so the cumprobs do not get properly graphed. When I make two
>separate charts they are both OK.
>
>At the same time the 'Simple test example' works well.
>
>New trial, this time with the option  PlotRange->{0,1} added.
>Now it works.
>
>What went wrong? The Help Browser says nothing about this in the BarChart
>article. Why doesn't BarChart[] calculate the PlotRange properly in 'My
>example'?
>
>Regards,
>Bjorn Leonardz
>
>-----------------------------------------------
>
><< Graphics`Graphics`
>
>** Simple test example
>testprobs = {.1, .2, .4, .2, .1};
>testcumprobs = {.1, .3, .7, .9, 1.};
>BarChart[testprobs, testcumprobs]
>
>** My example
>probs = {1, 3, 6, 9, 11, 13, 14, 13, 11, 9, 6, 3, 1}/100.
>cumprobs = {1, 4, 10, 19, 30, 43, 57, 70, 81, 90, 96, 99, 100}/100.
>BarChart[probs]
>BarChart[cumprobs]
>BarChart[probs, cumprobs]
>BarChart[probs, cumprobs, PlotRange->{0,1}]
>

<< Graphics`Graphics`

probs = {1, 3, 6, 9, 11, 13, 14, 13, 11, 9, 6, 3, 1}/100.;

cumprobs = FoldList[Plus, First[probs], Rest[probs]];

BarChart[probs, cumprobs];

BarChart[probs, cumprobs, PlotRange -> {0, 1}];

Mathematica frequently truncates graphs--not just barcharts--in an effort to 
improve the readability of the likely areas of interest. In trying to find a 
"compromise" view that conveys as much information as possible, the default 
sacrificed some display of the CDF. Whenever, its built-in algorithm 
truncates what you are interested in seeing, you can always specify the 
PlotRange. However, as you can see when you specified the PlotRange, it is 
difficult to read the values for the PDF. 

An alternate solution is to use separate axes for the PDF and CDF. For 
example, since the max value of the PDF is about 0.15

scale = 1/0.15;

BarChart[probs*scale, cumprobs, 
    Frame -> True, 
    FrameLabel -> {None, "PDF\n", None, "\nCDF"}, 
    FrameTicks -> {
        Automatic, 
        Join[Table[{y*scale, y}, {y, 0, .15, .03}], 
          Table[{y*scale, ""}, {y, 0, .15, .01}]], 
        None, 
        Join[Table[{y, y}, {y, 0, 1, .2}], 
          Table[{y, ""}, {y, 0, 1, .05}]]},  
    ImageSize -> {500, 328}];


Bob

BobHanlon at aol.com


  • Prev by Date: AW: ContourPlots,DensityPlots
  • Next by Date: Re: Multiple Headers in Data File
  • Previous by thread: Re: BarChart Bug?
  • Next by thread: Re: The 'Solving a Block Diagram in Mathematica' web page