Custom Colors on Mathematica RectangleChart Function

  • Context: Mathematica 
  • Thread starter Thread starter mhmounty
  • Start date Start date
  • Tags Tags
    Function Mathematica
Click For Summary

Discussion Overview

The discussion centers around customizing the color of rectangles in the RectangleChart function in Mathematica, specifically using a third variable to determine color intensity. The scope includes technical explanations and proposed solutions for visualizing data effectively.

Discussion Character

  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant seeks a method to color rectangles in RectangleChart based on a third variable, expressing difficulty with existing options like ChartStyle and Style.
  • Another participant suggests using Style to color individual rectangles or using ChartStyle with a list of colors, but this does not address the need for dynamic color scaling based on a numerical variable.
  • A participant clarifies that the third variable is a number scaled between 0 and 1, and requests a method to convert this list of numbers into corresponding colors for ChartStyle.
  • One participant proposes using the Map function with ColorData to convert a list of numbers into RGBColor entries, mentioning alternative color schemes available in Mathematica.
  • A later reply confirms the proposed solution works effectively for the participant's needs.

Areas of Agreement / Disagreement

Participants appear to agree on the need for a method to convert numerical values into colors, with one solution proposed and confirmed as effective. However, there is no consensus on the initial approach to coloring rectangles.

Contextual Notes

The discussion does not resolve the broader implications of color scaling or the limitations of the RectangleChart function in handling dynamic color assignments based on numerical data.

Who May Find This Useful

Users of Mathematica interested in data visualization, particularly those looking to customize chart aesthetics based on variable intensities.

mhmounty
Messages
10
Reaction score
0
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
 
Physics news on Phys.org
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
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
8K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
14K
  • · Replies 1 ·
Replies
1
Views
2K