Skip to content

Commit 958c65a

Browse files
committed
Merge pull request #12 from seijikun/heatmap
[HeatMapSeries] Update documentation
2 parents 49122ae + 517569f commit 958c65a

4 files changed

+152
-5
lines changed

models/series/HeatMapSeries.png

-17.5 KB
Binary file not shown.

models/series/HeatMapSeries.rst

+152-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ HeatMapSeries
66

77
A ``HeatMapSeries`` shows a 2D array of values as a heat map.
88

9-
.. image:: HeatMapSeries.png
10-
11-
129
Tracker
1310
-------
1411

@@ -28,9 +25,159 @@ To show the x and y values with one digit, use the format string ``"{2:0.0},{4:0
2825
The default format string for ``HeatMapSeries`` is ``"{0}\n{1}: {2}\n{3}: {4}\n{5}: {6}"``
2926

3027

31-
Example
28+
Example (Linear, Bitmap)
29+
-------
30+
31+
.. image:: HeatMapSeries_linear.png
32+
33+
.. sourcecode:: csharp
34+
35+
using OxyPlot;
36+
using OxyPlot.Axes;
37+
using OxyPlot.Series;
38+
39+
namespace ExampleLibrary
40+
{
41+
42+
public class LinearHeatMapViewModel
43+
{
44+
private PlotModel modelP1;
45+
public LinearHeatMapViewModel()
46+
{
47+
modelP1 = new PlotModel { Title = "Heatmap" };
48+
49+
//top axis
50+
modelP1.Axes.Add(new LinearColorAxis
51+
{
52+
Palette = OxyPalettes.Rainbow(100)
53+
});
54+
55+
//generate 1d normal distribution
56+
var singleData = new double[100];
57+
for(int x = 0; x < 100; ++x)
58+
singleData[x] = Math.Exp((-1.0 / 2.0) * Math.Pow(((double)x - 50.0) / 20.0, 2.0));
59+
//generate 2d normal distribution
60+
var data = new double[100, 100];
61+
for(int x = 0; x < 100; ++x)
62+
for(int y = 0; y < 100; ++y)
63+
data[y, x] = singleData[x] * singleData[(y + 30) % 100] * 100;
64+
65+
var heatMapSeries = new HeatMapSeries
66+
{
67+
X0 = 0,
68+
X1 = 99,
69+
Y0 = 0,
70+
Y1 = 99,
71+
Interpolate = true,
72+
RenderMethod = HeatMapRenderMethod.Bitmap,
73+
Data = data
74+
};
75+
76+
modelP1.Series.Add(heatMapSeries);
77+
78+
}
79+
80+
public PlotModel Model1
81+
{
82+
get { return modelP1; }
83+
set { modelP1 = value; }
84+
}
85+
}
86+
}
87+
88+
Example (Categorized, Rectangle)
3289
-------
3390

91+
The following diagram has categories on both, the x-axis and the y-axis.
92+
93+
It visualizes the amount of cake (y-axis) consumed on the specific day of week (x-axis). As can be seen in the diagram, the amount of cake rises from Monday to Sunday.
94+
95+
.. image:: HeatMapSeries_categorized.png
96+
3497
.. sourcecode:: csharp
3598

36-
var model = new PlotModel { Title = "HeatMapSeries" };
99+
using OxyPlot;
100+
using OxyPlot.Axes;
101+
using OxyPlot.Series;
102+
103+
namespace ExampleLibrary
104+
{
105+
106+
public class LinearHeatMapViewModel
107+
{
108+
private PlotModel modelP1;
109+
public LinearHeatMapViewModel()
110+
{
111+
modelP1 = new PlotModel { Title = "Cakes per Weekday" };
112+
113+
//WeekDay-Axis (Bottom)
114+
modelP1.Axes.Add(new CategoryAxis
115+
{
116+
Position = AxisPosition.Bottom,
117+
//Key used for specifying this axis in the HeatMapSeries
118+
Key = "WeekDayAxis",
119+
//Property of the items in ItemSource that should be used as title
120+
LabelField = "Title",
121+
//Array of Categories (see above), mapped to one of the coordinates of the 2D-data array
122+
ItemsSource = new Category[]
123+
{
124+
new Category{ Title = "Monday" },
125+
new Category{ Title = "Tuesday" },
126+
new Category{ Title = "Wednesday" },
127+
new Category{ Title = "Thursday" },
128+
new Category{ Title = "Friday" },
129+
new Category{ Title = "Saturday" },
130+
new Category{ Title = "Sunday" }
131+
}
132+
});
133+
//CakeType-Axis (Left)
134+
modelP1.Axes.Add(new CategoryAxis
135+
{
136+
Position = AxisPosition.Left,
137+
Key = "CakeAxis",
138+
LabelField = "Title",
139+
ItemsSource = new Category[]
140+
{
141+
new Category{ Title = "Apple cake" },
142+
new Category{ Title = "Baumkuchen" },
143+
new Category{ Title = "Bundt cake" },
144+
new Category{ Title = "Chocolate cake" },
145+
new Category{ Title = "Carrot cake" }
146+
}
147+
});
148+
//color axis
149+
modelP1.Axes.Add(new LinearColorAxis
150+
{
151+
Palette = OxyPalettes.Hot(200)
152+
});
153+
154+
var rand = new Random();
155+
var data = new double[7, 5];
156+
for(int x = 0; x < 5; ++x)
157+
for(int y = 0; y < 7; ++y)
158+
data[y, x] = rand.Next(0, 200) * (0.13 * (y + 1));
159+
160+
var heatMapSeries = new HeatMapSeries
161+
{
162+
X0 = 0,
163+
X1 = 6,
164+
Y0 = 0,
165+
Y1 = 4,
166+
XAxisKey = "WeekDayAxis",
167+
YAxisKey = "CakeAxis",
168+
RenderMethod = HeatMapRenderMethod.Rectangles,
169+
LabelFontSize = 0.2, //neccessary to display the label
170+
Data = data
171+
};
172+
173+
modelP1.Series.Add(heatMapSeries);
174+
175+
}
176+
177+
public PlotModel Model1
178+
{
179+
get { return modelP1; }
180+
set { modelP1 = value; }
181+
}
182+
}
183+
}
45 KB
Loading
93.8 KB
Loading

0 commit comments

Comments
 (0)