Difference between revisions of "Heat maps"

(graph style templates)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
''Requires [[Analytica 4.6]]''
+
[[Category: Graphs]]
  
[[image:Bar_HeatMap.png]]
+
__TOC__
[[image:Bar_HeatMap2.png]]
 
  
= Requirements =  
+
 
 +
:[[image:Bar_HeatMap.png]]
 +
 
 +
:[[image:Bar_HeatMap2.png]]
 +
 
 +
== Requirements ==  
 
The requirements for a heat map are
 
The requirements for a heat map are
 
* The indexes for both axes must be categorical.
 
* The indexes for both axes must be categorical.
Line 11: Line 15:
 
The indexes and the value must each contains no more than 30 distinct values. In the above graphs, the value contains only five distinct values.
 
The indexes and the value must each contains no more than 30 distinct values. In the above graphs, the value contains only five distinct values.
  
= Preparing your result variable =
+
== Preparing your result variable ==
  
In the above graph, correlation is a continuous quantity, but to create the heat map, it had to be mapped to five discrete categories first. To do this, an index named <code>Color_range</code> was created with the five labels.
+
Correlation is a continuous quantity, but to create the heat map, correlations are mapped into five discrete categories. First, you create an index named <code>Color_range</code> with the five labels:
  
[[image:heat map color range.png]]
+
:[[image:heat map color range.png]]
  
And a table was created with the lower bound of each range.
+
Then you create a table, <code>Bound</code>, with the lower bound of each range:
  
[[image:heat map bound.png]]
+
:[[image:heat map bound.png]]
  
You then use this to discretize the continuous correlation using [[StepInterp]].
+
You then use this to discretize the continuous correlations using [[StepInterp]].
  
[[StepInterp]]( Bound, Color_range, [[Abs]](Correlation_matrix), Color_range, leftLookup:true )
+
:<code>StepInterp(Bound, Color_range, Abs(Correlation_matrix), Color_range, leftLookup: True)</code>
  
The result is a 2-D array of labels.
+
The result is a 2-D array of labels:
  
[[image:heat map table.png]]
+
:[[image:heat map table.png]]
  
 
When you create a heat map, you are actually graphing textual (or at least categorical) labels.  
 
When you create a heat map, you are actually graphing textual (or at least categorical) labels.  
  
= Configuring the graph =
+
== Configuring the graph ==
  
Once you have a result that satisfies the requirements, you can create the heat map graph as follows.
+
Once you have a result that satisfies the requirements, you create the heat map graph:
#. Show the result graph
+
# Show the result graph
#. Double-click on the graph to go to graph setup.
+
# Double-click on the graph to go to graph setup.
#. Select Bar style. Set Overlap to 100%. Click '''Apply'''.
+
# Select Bar style. Set Overlap to 100%. Click '''Apply'''.
#. Set '''Key''' to be your main value. Set the '''Horizontal Axis''' and '''Vertical Axis''' to the two indexes. Cluster should be empty.
+
# Set '''Key''' to be your main value. Set the '''Horizontal Axis''' and '''Vertical Axis''' to the two indexes. Cluster should be empty.
#. Bring up graph setup again and click the '''Axis Ranges''' tab. Check '''Categorical''' for both axes. Press '''Apply'''.
+
# Bring up graph setup again and click the '''Axis Ranges''' tab. Check '''Categorical''' for both axes. Press '''Apply'''.
  
= Configuring colors =
+
== Configuring colors ==
  
You will most likely want to customize the colors of your heat map. To do so, right-click on any block and select '''Change Color Series...'''. From that dialog, customize the colors as desired. In most cases, you will probably want to leave the default as "General color sequence, this graph only.".
+
To customize the colors, right-click on any color block and select '''Change Color Series...'''. From that dialog, select the desired colors. In most cases, you will want to leave the default as "General color sequence, this graph only.".
  
= Encapsulating as a [[Graph_Style_Templates|graph style template]] =
+
== Encapsulating as a graph style template ==
  
If you plan on creating more than one heat map, you can save the graph setup and color customizations in a [[Graph_Style_Templates|graph style template]], which can then be used to streamline the process of configuring future heat maps. You have two options here: (1) Save all the graph settings, or (2) save just the customized color scheme.
+
If you want to create more than one heat map, you can save the graph setup and color customizations in a [[Graph_Style_Templates|graph style template]] to streamline the process of configuring future heat maps. You have two options here: (1) Save all the graph settings, or (2) save just the customized color scheme.
  
== Saving all graph settings ==
+
=== Saving all graph settings ===
  
 
To create a graph style template with all the graph setup changes, show your result graph, then:
 
To create a graph style template with all the graph setup changes, show your result graph, then:
#. Double-click on the background to bring up graph setup
+
# Double-click on the background to bring up graph setup
#. In the '''Style template:''' field at the bottom, select '''New Template'''.
+
# In the '''Style template:''' field at the bottom, select '''New Template'''.
#. Type a name for the template, e.g., ''Heat map blue''
+
# Type a name for the template, e.g., ''Heat map blue''
 
#. Press '''Set Template'''
 
#. Press '''Set Template'''
  
 
With this graph style template now created, you can create a second heat map with fewer steps:
 
With this graph style template now created, you can create a second heat map with fewer steps:
#. Create indexes and a variable meeting the requirements at the beginning of this page.
+
# Create indexes and a variable meeting the requirements at the beginning of this page.
#. Show the result graph, go to graph setup and select "Heat map blue" for the '''Style template'''. Press '''Apply'''.
+
# Show the result graph, go to graph setup and select "Heat map blue" for the '''Style template'''. Press '''Apply'''.
#. Set '''Key''' to be your main value. Set the '''Horizontal Axis''' and '''Vertical Axis''' to the two indexes. Cluster should be empty.
+
# Set '''Key''' to be your main value. Set the '''Horizontal Axis''' and '''Vertical Axis''' to the two indexes. Cluster should be empty.
#. Bring up graph setup again and click the '''Axis Ranges''' tab. Check '''Categorical''' for both axes. Press '''Apply'''.
+
# Bring up graph setup again and click the '''Axis Ranges''' tab. Check '''Categorical''' for both axes. Press '''Apply'''.
  
 
The last step will not be necessary if you are using the same indexes used in the first heat map, or if the indexes are already categorical.
 
The last step will not be necessary if you are using the same indexes used in the first heat map, or if the indexes are already categorical.
  
== Saving only the color series ==
+
=== Saving only the color series ===
  
I actually prefer saving just the custom color series into the graph style template, without all the other graph settings mixed in. This allows me to select the custom color series in any context without altering graph settings that might not apply if I'm using the colors for something else.
+
We actually prefer saving just the custom color series into the graph style template, without all the other graph settings mixed in. This allows us to select the custom color series in any context without altering graph settings that might not apply if we are using the colors for something else.
  
 
To do this, you need to first create an empty graph style template. To do that,  
 
To do this, you need to first create an empty graph style template. To do that,  
#. create a new variable, <code>Va1</code>, define it as <code>Time</code>
+
# create a new variable, <code>Va1</code>, define it as [[Time]]
#. show its graph and double-click to Graph Setup.  
+
# show its graph and double-click to [[Graph setup dialog|Graph Setup]].  
#. Select '''New Template''' in the '''Style Template''' control at the bottom and type a name, say "Blue heat colors" (without quotes)
+
# Select '''New Template''' in the '''Style Template''' control at the bottom and type a name, say <code>Blue heat colors</code>
#. Press '''Set Template'''
+
# Press '''Set Template'''
#. Delete <code>Va1</code> -- you're done with it.
+
# Delete <code>Va1</code> -- you're done with it.
#*At this point, "blue heat colors" has been created as a new graph style template, but is empty, since <code>Va1</code> had no graph settings configured.
+
#*At this point, <code>blue heat colors</code> has been created as a new graph style template, but is empty, since <code>Va1</code> had no graph settings configured.
#. Show your heat map graph and double-click to its Graph Setup.
+
# Show your heat map graph and double-click to its Graph Setup.
#. Set '''Style Template''' to "Blue heat colors" and press '''Apply'''
+
# Set '''Style Template''' to <code>Blue heat colors</code> and press '''Apply'''
#. Right-click on a colored block on the graph and select '''Change Series Colors...'''
+
# Right-click on a colored block on the graph and select '''Change Series Colors...'''
#. Select the '''apply to the graph style template''' radio button option.  Press '''OK'''.
+
# Select the '''apply to the graph style template''' radio button option.  Press '''OK'''.
  
To apply these colors to another graph, you'll set the Style template in graph setup to "Blue heat colors" and press '''Apply'''.
+
To apply these colors to another graph, you'll set the Style template in graph setup to <code>Blue heat colors</code> and press '''Apply'''.
  
= Download an example =
+
== Download an example ==
  
 
Download a [[media:Heat map.ana|Heat map.ana]] example model.
 
Download a [[media:Heat map.ana|Heat map.ana]] example model.
  
= See Also =
+
==History==
 +
Introduced in [[Analytica 4.6]].
  
 +
== See Also ==
 +
* [[media:Heat map.ana|Heat map.ana]]
 +
* [[Graph settings]]
 +
* [[Graph setup dialog]]
 +
* [[Graph Style Templates]]
 +
* [[Contour/Region Charts]]
 +
* [[Stacked clustered bar charts]]
 
* [[Analytica_Modelers_Guide#Mini-Tutorials|Mini-Tutorials]] where other esoteric graph types are described.
 
* [[Analytica_Modelers_Guide#Mini-Tutorials|Mini-Tutorials]] where other esoteric graph types are described.

Latest revision as of 23:48, 16 February 2016



Bar HeatMap.png
Bar HeatMap2.png

Requirements

The requirements for a heat map are

  • The indexes for both axes must be categorical.
  • The value depicted by color must be categorical.

The indexes and the value must each contains no more than 30 distinct values. In the above graphs, the value contains only five distinct values.

Preparing your result variable

Correlation is a continuous quantity, but to create the heat map, correlations are mapped into five discrete categories. First, you create an index named Color_range with the five labels:

Heat map color range.png

Then you create a table, Bound, with the lower bound of each range:

Heat map bound.png

You then use this to discretize the continuous correlations using StepInterp.

StepInterp(Bound, Color_range, Abs(Correlation_matrix), Color_range, leftLookup: True)

The result is a 2-D array of labels:

Heat map table.png

When you create a heat map, you are actually graphing textual (or at least categorical) labels.

Configuring the graph

Once you have a result that satisfies the requirements, you create the heat map graph:

  1. Show the result graph
  2. Double-click on the graph to go to graph setup.
  3. Select Bar style. Set Overlap to 100%. Click Apply.
  4. Set Key to be your main value. Set the Horizontal Axis and Vertical Axis to the two indexes. Cluster should be empty.
  5. Bring up graph setup again and click the Axis Ranges tab. Check Categorical for both axes. Press Apply.

Configuring colors

To customize the colors, right-click on any color block and select Change Color Series.... From that dialog, select the desired colors. In most cases, you will want to leave the default as "General color sequence, this graph only.".

Encapsulating as a graph style template

If you want to create more than one heat map, you can save the graph setup and color customizations in a graph style template to streamline the process of configuring future heat maps. You have two options here: (1) Save all the graph settings, or (2) save just the customized color scheme.

Saving all graph settings

To create a graph style template with all the graph setup changes, show your result graph, then:

  1. Double-click on the background to bring up graph setup
  2. In the Style template: field at the bottom, select New Template.
  3. Type a name for the template, e.g., Heat map blue
  4. . Press Set Template

With this graph style template now created, you can create a second heat map with fewer steps:

  1. Create indexes and a variable meeting the requirements at the beginning of this page.
  2. Show the result graph, go to graph setup and select "Heat map blue" for the Style template. Press Apply.
  3. Set Key to be your main value. Set the Horizontal Axis and Vertical Axis to the two indexes. Cluster should be empty.
  4. Bring up graph setup again and click the Axis Ranges tab. Check Categorical for both axes. Press Apply.

The last step will not be necessary if you are using the same indexes used in the first heat map, or if the indexes are already categorical.

Saving only the color series

We actually prefer saving just the custom color series into the graph style template, without all the other graph settings mixed in. This allows us to select the custom color series in any context without altering graph settings that might not apply if we are using the colors for something else.

To do this, you need to first create an empty graph style template. To do that,

  1. create a new variable, Va1, define it as Time
  2. show its graph and double-click to Graph Setup.
  3. Select New Template in the Style Template control at the bottom and type a name, say Blue heat colors
  4. Press Set Template
  5. Delete Va1 -- you're done with it.
    • At this point, blue heat colors has been created as a new graph style template, but is empty, since Va1 had no graph settings configured.
  6. Show your heat map graph and double-click to its Graph Setup.
  7. Set Style Template to Blue heat colors and press Apply
  8. Right-click on a colored block on the graph and select Change Series Colors...
  9. Select the apply to the graph style template radio button option. Press OK.

To apply these colors to another graph, you'll set the Style template in graph setup to Blue heat colors and press Apply.

Download an example

Download a Heat map.ana example model.

History

Introduced in Analytica 4.6.

See Also

Comments


You are not allowed to post comments.