# Custom Colors on Mathematica RectangleChart Function

• Mathematica
• mhmounty
In summary, the conversation discusses the use of the RectangleChart function in Mathematica and how to color each rectangle using a third variable. The suggested methods include using the Style or ChartStyle options, with examples provided. The conversation also mentions the use of color gradients, specifically mentioning the "Rainbow" and "TemperatureMap" options. The Map function is suggested as a way to convert a list of numbers into a list of RGBColor entries.
mhmounty
I have data in x,y pairs that I am passing to the RectangleChart function in Mathematica. But I want to be able to color each of those rectangles using a third variable z. There seems to be no easy way to do this. I can't get the ChartStyle or Style options to add this color. Anybody know of a good way to do this?

-J

let's say you have an x, y pair like this:

RectangleChart[{...,{x,y},...},...]

And let's say you wanted it colored Red. Then you would use:

RectangleChart[{...,Style[{x,y},Red],...},...]

Or alternatively

RectangleChart[{...,{x,y},...},...,ChartStyle->{...,Red,...}]

Where the ChartStyle option was a list with as many elements as your data.

Thanks for the reply. But I think I was a little bit unclear on my first post. The third value in the list is a number, scaled between 0 and 1. So it's not a color name. And I want to show the intensity of that number with color.

When I have the list of numbers, scaled 0 to 1, I can't find a way to convert that to a list of colors. GrayLevel[] or Hue[] will not work on a list.

Anybody else got an idea on how to take a list of numbers, ie., a = {0.5, 0.6, 0.9} and convert that to a list of colors for the ChartStyle option to work?

-J

To convert "a" from a list of numbers into a list of RGBColor entries use:

Map[ColorData["Rainbow"][#]&,a]

If you search in the help for "color schemes" you will find a pretty long list of color gradients that you can use instead of "Rainbow". My favorites are "Rainbow" and "TemperatureMap".

Thanks so much! The Map function does it perfectly.

-J

## What is the purpose of the RectangleChart function in Mathematica?

The RectangleChart function in Mathematica is used for creating bar charts or histograms with rectangular bars. It allows users to visualize and compare data in a graphical format.

## Can I change the default colors of the bars in a RectangleChart?

Yes, you can customize the colors of the bars in a RectangleChart by using the "ChartStyle" option. This allows you to specify a list of colors that will be applied to the bars in the order they appear in the chart.

## How do I create custom color schemes for my RectangleChart?

To create a custom color scheme for your RectangleChart, you can use the "ColorFunction" option. This allows you to specify a function that will be applied to each bar in the chart, allowing for more complex color schemes based on the data.

## Is it possible to add labels to the bars in a RectangleChart?

Yes, you can add labels to the bars in a RectangleChart by using the "ChartLabels" option. This allows you to specify a list of labels that will be placed above each bar in the chart.

## Can I customize the appearance of the axes and gridlines in a RectangleChart?

Yes, you can customize the appearance of the axes and gridlines in a RectangleChart by using the "AxesStyle" and "GridLinesStyle" options. These allow you to specify different colors, thickness, and other properties for the axes and gridlines in the chart.

• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
• MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
• Programming and Computer Science
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
• MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
5K