Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: BarChart and Ticks problem.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73224] Re: [mg73179] BarChart and Ticks problem.
  • From: Darren Glosemeyer <darreng at wolfram.com>
  • Date: Thu, 8 Feb 2007 03:35:40 -0500 (EST)
  • References: <200702060839.DAA25155@smc.vnet.net>

luhaorice at gmail.com wrote:
> Hello, All
> I have a problem with BarChart and Ticks.
>
> Needs["Statistics`DataManipulation`"];
> Needs["Graphics`Graphics`"];
> sid = N[Table[Sin[Pi Random[]], {1000}]];
> freqtst = BinCounts[sid, {0, 1, 0.02}];
> midp = Table[i, {i, 0.02, 1, 0.02}];
> BarChart[Transpose[{freqtst, midp}]]
> (* The ticks on X axis is correct except crowded*)
> Show[%, Ticks -> Automatic]
> (*here, I have the wrong X axis ticks.  The range of the ticks is from
> 0 to 50 which doesn't make any sense because Sin[x] is always less or
> equal than 1. *)
>
> ListPlot[Transpose[{midp, freqtst}], Ticks -> Automatic]
> (* this gives me the right answer*)
>
> Any suggestions?
> Thanks!
>
>   

BarChart places it's first bar at 1, the second at 2 and so on. The 
Automatic Ticks setting shows the underlying scale of the graphic. Note 
that the labels for the bars in general could be non-numeric things like 
text or symbols.

I think you should be able to get the chart desired using Histogram. For 
instance,

Histogram[sid, HistogramCategories -> Range[0, 1, .02]]

will bin the data in bins of width .02 and plot the bars on a linear scale.

To get the same ticks placed at the center of the bars, the data and the 
HistogramCategories could be shifted by half of a bin width as in the 
following.

Histogram[sid + .01, HistogramCategories -> Range[0, 1, .02] + .01]

I hope this helps.

Darren Glosemeyer
Wolfram Research


  • Prev by Date: Re: Fwd: Re: subscribe
  • Next by Date: Re: Passing a list as seperate parameters?
  • Previous by thread: BarChart and Ticks problem.
  • Next by thread: Re: BarChart and Ticks problem.