MathGroup Archive 2009

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

Search the Archive

Re: BarChart - Extendng the Y-axis and labeling the endpoints

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97612] Re: BarChart - Extendng the Y-axis and labeling the endpoints
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 17 Mar 2009 04:57:33 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <gphds3$om3$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,


BarChart[{1, 2, -1.3, 2.4}, PlotRangePadding -> {None, 0.2}]

??

Regards
   Jens

Donald DuBois wrote:
> Here is a BarChart (almost directly  from the Mathematica Documentation):
> 
> Needs["BarCharts`"]
> 
> thisBarChart = BarChart[{1, 2, -1.3, 2.4}]
> 
> I am trying to extend the labeling of the Y-axis so that the endpoints of the Y-axs extend a little beyond
> the extremes of the data  in the Y direction (the extremes of the data
> being -1.3 and 2.4) and these endpoints are labeled with
> multiples of the chosen increment. 
> 
> I believe this makes the BarChart easier to read and is aesthetically more pleasing.  
> 
> For example, with the above
> evaluation of BarChart,  the labeling of the Y-axis  goes from 2.0 to -1.0 in increments of 0.5 as chosen by Mathematica but the Y-axis itself extends
> beyond these labels. 
> 
>   I would like to extend the labeling in both directions (positive and negative sides
>  along the Y-axis)  to the nearest integral multiple of 
>   the increment that Mathematica has chosen so the Y-axis
>   would be extended slightly beyond the extremes of the data and the endpoints of the Y-axis would have labels.
> 
> In this example,  the Y-axis would be extended from 2.5 to -1.5 and the labeling would go from  
> 
> { -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0} to  
> 
> {-1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5} 
> 
> with the labeling being integral multiples of the chosen increment.   
>    
> To do this, I need to know that the automatic labeling is in increments of 0.5 (as chosen by Mathematica) and then I need to extend the endpoint labels from {-1.0, 2.0} to  {-1.5, 2.5}. 
> 
> I can get the PlotRange that is chosen by Mathematica   automatically by using  AbsoluteOptions on the graphical object called thisBarChart: 
> 
> AbsoluteOptions[thisBarChart, PlotRange]   
> 
> which produces
> 
> {PlotRange -> {{0.4, 4.6}, {-1.3, 2.4}}}
> 
> But, I still don't know the increment that Mathematica used so that I can force the labeling to a high of 2.5 and a minimum of -1.5.
> 
> There's another complication:
> 
> Assuming I did know (by magic) that the chosen increment was 0.5 for the labeling I thought I could then use
> 
> BarChart[{1, 2, -1.3, 2.4}, PlotRange -> {Automatic, { 2.5, -1.5}}]
> 
> to extend  the Y-axis endpoints with labels of -1.5, and 2.5  but this doesn't work because the endpoints of the Y-azis are not labeled.
> 
> I find, through experimentation only, that what I need is:
> 
> BarChart[{1, 2, -1.3, 2.4}, PlotRange -> {Automatic, {3.0, -2.0}}]
> 
> and the increment for the labeling has automatically changed to 1  (the fact that the increment has changed from 0.5 to 1.0 in this case is not a problem.)
> 
> How can I get Mathematica to do this in a programmatic way so that I don't need to experiment each time to (1) get the Y-axis extended  a little
> beyond the extremes of the data  and (2) the endpoints 
> labeled with integral multiples of the chosen increment?  
> 
> Thank you in advance for any help you can give me.
> 


  • Prev by Date: Import [ #, Data ]&
  • Next by Date: Re: Using Mathematica notebooks in presentations?
  • Previous by thread: BarChart - Extendng the Y-axis and labeling the endpoints
  • Next by thread: Re: Function as return value, how to document it