alternating colors of bars in Histogram (Mathematica 7)
- To: mathgroup at smc.vnet.net
- Subject: [mg94052] alternating colors of bars in Histogram (Mathematica 7)
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Wed, 3 Dec 2008 05:44:07 -0500 (EST)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- Reply-to: murray at math.umass.edu
With the old Histogram` package in Mathematica 6, I could alternate the
colors of the bars using a Style option, e.g.:
<<Histograms`
Histogram[RandomReal[NormalDistribution[50,10], 200],
HistogramCategories -> Range[0, 100, 5],
BarStyle -> {Red, Blue}]
How do I accomplish the same thing with the built-in Histogram function
in Mathematica 7? The documentation seems to suggest using the
ChartStyle option, and the ref page on ChartStyle even says,
"ChartStyle->{Subscript[g, 1],Subscript[g, 2],\[Ellipsis]} specifies
that successive directives Subscript[g, i] should be used cyclically for
successive elements in each dataset."
Nonetheless, the following in Mathematica 7 (without loading the old
package) colors all the bars Red:
Histogram[RandomReal[NormalDistribution[50, 10], 200], {0, 100, 5},
ChartStyle -> {Red, Blue}]
Perhaps ColorFunction is the option to use, but I don't see how to make
it depend upon the bin rather than upon the height.
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305