Skip to content

Commit 921447a

Browse files
authored
Implement LogarithmicColorAxis (#2049)
1 parent ce7d467 commit 921447a

28 files changed

+994
-675
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
1414
- Border properties on PathAnnotation to match functionality in TextAnnotation (#1900)
1515
- Expanded `IntervalBarSeries` and `TornadoBarSeries` to allow for varied label positions and angles (#2027)
1616
- VectorSeries (#107)
17+
- LogarithmicColorAxis (#92)
1718

1819
### Changed
1920
- Make consistent BaseValue and BaseLine across BarSeries, LinearBarSeries, and HistogramSeries
@@ -24,6 +25,7 @@ All notable changes to this project will be documented in this file.
2425
- Run tests on both .NET Framework 4.6.2 and .NET 6.0 (#1937)
2526
- Add support for .NET 7.0 (#1937)
2627
- Update SkiaSharp to Version 2.88.6
28+
- AxisRendererBase is now generic
2729

2830
### Removed
2931
- Support for .NET Framework 4.0 and 4.5 (#1839)

Source/Examples/ExampleLibrary/Axes/LinearColorAxisExamples.cs

Lines changed: 25 additions & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -8,225 +8,45 @@ namespace ExampleLibrary
88
{
99
using OxyPlot;
1010
using OxyPlot.Axes;
11+
using System.Linq;
1112

1213
[Examples("LinearColorAxis"), Tags("Axes")]
1314
public class LinearColorAxisExamples
1415
{
15-
[Example("Default palette")]
16-
public static PlotModel DefaultPalette()
16+
private static PlotModel EnableRenderAsImage(PlotModel plotModel)
1717
{
18-
var model = HeatMapSeriesExamples.CreatePeaks(null, false);
19-
model.Axes.Clear();
20-
model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right });
21-
return model;
22-
}
23-
24-
[Example("Jet (200 colors) palette")]
25-
public static PlotModel Jet200()
26-
{
27-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(200), false);
28-
}
29-
30-
[Example("Jet (20 colors) palette")]
31-
public static PlotModel Jet20()
32-
{
33-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(20), false);
34-
}
35-
36-
[Example("Hue (400 colors) palette")]
37-
public static PlotModel Hue400()
38-
{
39-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Hue(400), false);
40-
}
41-
42-
[Example("Hue distinct (200 colors) palette")]
43-
public static PlotModel HueDistinct200()
44-
{
45-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.HueDistinct(200), false);
46-
}
47-
48-
[Example("Hue distinct reversed (200 colors) palette")]
49-
public static PlotModel HueDistinctReverse200()
50-
{
51-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.HueDistinct(200).Reverse(), false);
52-
}
53-
54-
[Example("Hot (200 colors) palette")]
55-
public static PlotModel Hot200()
56-
{
57-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Hot(200), false);
58-
}
59-
60-
[Example("Hot (64 colors) palette")]
61-
public static PlotModel Hot64()
62-
{
63-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Hot64, false);
18+
var axis = plotModel.Axes.OfType<LinearColorAxis>().Single();
19+
axis.RenderAsImage = true;
20+
plotModel.Title += " - RenderAsImage";
21+
return plotModel;
6422
}
6523

66-
[Example("Hot (30 colors) palette")]
67-
public static PlotModel Hot30()
24+
[Example("Peaks")]
25+
public static PlotModel Peaks()
6826
{
69-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Hot(30), false);
27+
return HeatMapSeriesExamples.CreatePeaks(null, false);
7028
}
7129

72-
[Example("Blue-white-red (200 colors) palette")]
73-
public static PlotModel BlueWhiteRed200()
30+
[Example("Peaks - RenderAsImage")]
31+
public static PlotModel PeaksRenderAsImage()
7432
{
75-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlueWhiteRed(200), false);
33+
return EnableRenderAsImage(Peaks());
7634
}
7735

78-
[Example("Blue-white-red (40 colors) palette")]
79-
public static PlotModel BlueWhiteRed40()
80-
{
81-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlueWhiteRed(40), false);
82-
}
83-
84-
[Example("Black-white-red (500 colors) palette")]
85-
public static PlotModel BlackWhiteRed500()
86-
{
87-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlackWhiteRed(500), false);
88-
}
89-
90-
[Example("Black-white-red (3 colors) palette")]
91-
public static PlotModel BlackWhiteRed3()
92-
{
93-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.BlackWhiteRed(3), false);
94-
}
95-
96-
[Example("Cool (200 colors) palette")]
97-
public static PlotModel Cool200()
98-
{
99-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Cool(200), false);
100-
}
101-
102-
[Example("Rainbow (200 colors) palette")]
103-
public static PlotModel Rainbow200()
104-
{
105-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Rainbow(200), false);
106-
}
107-
108-
[Example("Viridis palette")]
109-
public static PlotModel Viridis()
110-
{
111-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Viridis(), false);
112-
}
113-
114-
[Example("Plasma palette")]
115-
public static PlotModel Plasma()
116-
{
117-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Plasma(), false);
118-
}
119-
120-
[Example("Magma palette")]
121-
public static PlotModel Magma()
122-
{
123-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Magma(), false);
124-
}
125-
126-
[Example("Inferno palette")]
127-
public static PlotModel Inferno()
128-
{
129-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Inferno(), false);
130-
}
131-
132-
[Example("Cividis palette")]
133-
public static PlotModel Cividis()
134-
{
135-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Cividis(), false);
136-
}
137-
138-
[Example("Viridis (10 colors) palette")]
139-
public static PlotModel Viridis10()
140-
{
141-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Viridis(10), false);
142-
}
143-
144-
[Example("Rainbow (7 colors) palette")]
145-
public static PlotModel Rainbow7()
146-
{
147-
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Rainbow(7), false);
148-
}
149-
150-
[Example("Vertical (6 colors)")]
151-
public static PlotModel Vertical_6()
36+
[Example("6 Colors")]
37+
public static PlotModel Horizontal6()
15238
{
15339
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false);
15440
}
15541

156-
[Example("Vertical reverse (6 colors)")]
157-
public static PlotModel Vertical_Reverse_6()
158-
{
159-
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false);
160-
var colorAxis = (LinearColorAxis)model.Axes[0];
161-
colorAxis.StartPosition = 1;
162-
colorAxis.EndPosition = 0;
163-
return model;
164-
}
165-
166-
[Example("Horizontal (6 colors)")]
167-
public static PlotModel Horizontal_6()
168-
{
169-
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false);
170-
var colorAxis = (LinearColorAxis)model.Axes[0];
171-
colorAxis.Position = AxisPosition.Top;
172-
return model;
173-
}
174-
175-
[Example("Horizontal reverse (6 colors)")]
176-
public static PlotModel Horizontal_Reverse_6()
177-
{
178-
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false);
179-
var colorAxis = (LinearColorAxis)model.Axes[0];
180-
colorAxis.Position = AxisPosition.Top;
181-
colorAxis.StartPosition = 1;
182-
colorAxis.EndPosition = 0;
183-
return model;
184-
}
185-
186-
[Example("RenderAsImage (horizontal)")]
187-
public static PlotModel RenderAsImage_Horizontal()
188-
{
189-
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(1000), false);
190-
var colorAxis = (LinearColorAxis)model.Axes[0];
191-
colorAxis.RenderAsImage = true;
192-
colorAxis.Position = AxisPosition.Top;
193-
return model;
194-
}
195-
196-
[Example("RenderAsImage (horizontal reversed)")]
197-
public static PlotModel RenderAsImage_Horizontal_Reversed()
42+
[Example("6 Colors - RenderAsImage")]
43+
public static PlotModel Horizontal6RenderAsImage()
19844
{
199-
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(1000), false);
200-
var colorAxis = (LinearColorAxis)model.Axes[0];
201-
colorAxis.RenderAsImage = true;
202-
colorAxis.Position = AxisPosition.Top;
203-
colorAxis.StartPosition = 1;
204-
colorAxis.EndPosition = 0;
205-
return model;
45+
return EnableRenderAsImage(Horizontal6());
20646
}
20747

208-
[Example("RenderAsImage (vertical)")]
209-
public static PlotModel RenderAsImage_Vertical()
210-
{
211-
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(1000), false);
212-
var colorAxis = (LinearColorAxis)model.Axes[0];
213-
colorAxis.RenderAsImage = true;
214-
return model;
215-
}
216-
217-
[Example("RenderAsImage (vertical reversed)")]
218-
public static PlotModel RenderAsImage_Vertical_Reversed()
219-
{
220-
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(1000), false);
221-
var colorAxis = (LinearColorAxis)model.Axes[0];
222-
colorAxis.RenderAsImage = true;
223-
colorAxis.StartPosition = 1;
224-
colorAxis.EndPosition = 0;
225-
return model;
226-
}
227-
228-
[Example("Short vertical")]
229-
public static PlotModel Vertical_Short()
48+
[Example("Short")]
49+
public static PlotModel Short()
23050
{
23151
var model = HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(600), false);
23252
var colorAxis = (LinearColorAxis)model.Axes[0];
@@ -235,6 +55,12 @@ public static PlotModel Vertical_Short()
23555
return model;
23656
}
23757

58+
[Example("Short - RenderAsImage")]
59+
public static PlotModel ShortRenderAsImage()
60+
{
61+
return EnableRenderAsImage(Short());
62+
}
63+
23864
[Example("Position None")]
23965
public static PlotModel Position_None()
24066
{
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="LogarithmicColorAxisExamples.cs" company="OxyPlot">
3+
// Copyright (c) 2014 OxyPlot contributors
4+
// </copyright>
5+
// --------------------------------------------------------------------------------------------------------------------
6+
7+
namespace ExampleLibrary
8+
{
9+
using OxyPlot;
10+
using OxyPlot.Axes;
11+
using OxyPlot.Series;
12+
using System.Linq;
13+
14+
[Examples("LogarithmicColorAxis"), Tags("Axes")]
15+
public class LogarithmicColorAxisExamples
16+
{
17+
private static PlotModel ConvertToLogarithmic(PlotModel model)
18+
{
19+
var linearAxis = model.Axes.OfType<LinearColorAxis>().Single();
20+
model.Axes.Remove(linearAxis);
21+
var logarithmicAxis = new LogarithmicColorAxis()
22+
{
23+
Position = linearAxis.Position,
24+
Palette = linearAxis.Palette,
25+
StartPosition = linearAxis.StartPosition,
26+
EndPosition = linearAxis.EndPosition,
27+
HighColor = linearAxis.HighColor,
28+
LowColor = linearAxis.LowColor,
29+
InvalidNumberColor = linearAxis.InvalidNumberColor,
30+
};
31+
32+
var series = model.Series.OfType<HeatMapSeries>().Single();
33+
for (int x = 0; x < series.Data.GetLength(0); x++)
34+
for (int y = 0; y < series.Data.GetLength(1); y++)
35+
{
36+
series.Data[x, y] += 6.6;
37+
}
38+
39+
model.Axes.Add(logarithmicAxis);
40+
return model;
41+
}
42+
43+
[Example("Peaks")]
44+
public static PlotModel Peaks()
45+
{
46+
return ConvertToLogarithmic(LinearColorAxisExamples.Peaks());
47+
}
48+
49+
[Example("Peaks - RenderAsImage")]
50+
public static PlotModel PeaksRenderAsImage()
51+
{
52+
return ConvertToLogarithmic(LinearColorAxisExamples.PeaksRenderAsImage());
53+
}
54+
55+
[Example("6 colors")]
56+
public static PlotModel Horizontal6()
57+
{
58+
return ConvertToLogarithmic(LinearColorAxisExamples.Horizontal6());
59+
}
60+
61+
[Example("6 colors - RenderAsImage")]
62+
public static PlotModel Horizontal6RenderAsImage()
63+
{
64+
return ConvertToLogarithmic(LinearColorAxisExamples.Horizontal6RenderAsImage());
65+
}
66+
67+
[Example("Short")]
68+
public static PlotModel Short()
69+
{
70+
return ConvertToLogarithmic(LinearColorAxisExamples.Short());
71+
}
72+
73+
[Example("Short - RenderAsImage")]
74+
public static PlotModel ShortRenderAsImage()
75+
{
76+
return ConvertToLogarithmic(LinearColorAxisExamples.ShortRenderAsImage());
77+
}
78+
79+
[Example("Position None")]
80+
public static PlotModel Position_None()
81+
{
82+
return ConvertToLogarithmic(LinearColorAxisExamples.Position_None());
83+
}
84+
}
85+
}

Source/Examples/ExampleLibrary/ExampleLibrary.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
66
<Description>Example models for OxyPlot.</Description>
77
<PackageTags>plotting plot charting chart</PackageTags>
8+
<LangVersion>11</LangVersion>
89
</PropertyGroup>
910
<ItemGroup>
1011
<None Remove="Resources\DodgyContourData.tsv" />

0 commit comments

Comments
 (0)