程阳:Create Heat Maps Using Excel

标签:
程阳彩票createheatmapsusingexcelit |
分类: 信息科技 |
程阳:Create Heat Maps Using Excel
Heat
Maps are an excellent way to present a lot of data in a
single view, and can be created using Excel.
The way to create a
Heat Mapwith Excel is to select the Surface Chart
type.
By default, Excel's surface charts display black lines between each color gradient, which makes the chart look strange (and not like a heat map).
Click the chart legend to
select it
Click the first legend key (that is the small colored square)
Right-click and choose Format Legend Key
In the Format Legend Key dialog box, click the Patterns tab
Select None for the Border option, and click OK
Repeat those steps for every series in your chart.
If you want to do it automatically, you can use the following macro:
Sub
RemoveLinesandSetColors()
Dim LE As Integer
Dim red As Integer
Dim green As Integer
Dim blue As Integer
Dim a As Integer
Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim q As Integer
red = 0
green = 0
blue = 255
LE = 1
If ActiveChart Is Nothing
Then Exit Sub
If MsgBox("Remove lines from surface chart and set colors?",
vbYesNo) = vbYes Then
Application.ScreenUpdating = False
ActiveChart.HasLegend = True
a = ActiveChart.Legend.LegendEntries.Count
x = a / 4
y = Int(255 / x)
For z = 1 To 4
For q = 1 To x
ActiveChart.Legend.LegendEntries(LE).LegendKey.Border.LineStyle =
xlNone
ActiveChart.Legend.LegendEntries(LE).LegendKey.Interior.Color =
RGB(red, green, blue)
If z = 1 Then green = green + y
If z = 2 Then blue = blue - y
If z = 3 Then red = red + y
If z = 4 Then green = green - y
LE = LE + 1
Next q
q = 1
Next z
End If
End Sub
To use this macro, copy it and paste it to a VBA module. Then,
select a surface chart and press Alt+F8 to display the Macro dialog
box. Execute the RemoveLinesandSetColors macro, and your chart will
be changed. Note that the macro also changes the color scale to a
blue-to-red spectrum.
The number of colored
gradients in a surface chart is determined by the Major Unit
setting for the vertical axis. Right-click the legend and select
the Scale tab.
One note:
This VBA macro above not
only removes the lines, but sets the color scale to a spectrum from
blue to red, with blue being low values and red being
high.
I hope this helps you as you try to create a Heat Map in Excel.
(Heatmap 翻译为“级图”,意为“等级图”。一些早前的说法,“热图”、“数据地图”、“数图”等等均有歧义,容易混淆,故不宜采用——
“热力图”是工程热力学专门术语
“热图”多与情-色相关
“数图”数字图书馆
“数据地图”大多数行业应用与“地图”无关
“数据图”太宽泛,没有针对性)
程阳:Create