Skip to content

Commit 66a6751

Browse files
committed
fixed incorrect placment of axis title of axes with AxisDistance (#1065)
1 parent 82816b1 commit 66a6751

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ All notable changes to this project will be documented in this file.
109109
- ListFiller (#705)
110110

111111
### Fixed
112+
- Incorrect placment of axis title of axes with AxisDistance (#1065)
112113
- SharpDX control not being rendered when loaded
113114
- SharpDX out of viewport scrolling.
114115
- Multiple mouse clicks not being reported in OxyPlot.GtkSharp (#854)

Source/Examples/ExampleLibrary/Issues/Issues.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,43 @@ public static PlotModel NormalHeatMap()
11571157
return model;
11581158
}
11591159

1160+
[Example("#1065: LinearColorAxis Title")]
1161+
public static PlotModel ColorAxisTitle()
1162+
{
1163+
int n = 100;
1164+
1165+
double x0 = -3.1;
1166+
double x1 = 3.1;
1167+
double y0 = -3;
1168+
double y1 = 3;
1169+
Func<double, double, double> peaks = (x, y) => 3 * (1 - x) * (1 - x) * Math.Exp(-(x * x) - (y + 1) * (y + 1)) - 10 * (x / 5 - x * x * x - y * y * y * y * y) * Math.Exp(-x * x - y * y) - 1.0 / 3 * Math.Exp(-(x + 1) * (x + 1) - y * y);
1170+
var xvalues = ArrayBuilder.CreateVector(x0, x1, n);
1171+
var yvalues = ArrayBuilder.CreateVector(y0, y1, n);
1172+
var peaksData = ArrayBuilder.Evaluate(peaks, xvalues, yvalues);
1173+
1174+
var model = new PlotModel { Title = "Peaks" };
1175+
1176+
model.Axes.Add(new LinearAxis() { Key = "x_axis", AbsoluteMinimum = x0, AbsoluteMaximum = x1, Position = AxisPosition.Top });
1177+
1178+
model.Axes.Add(new LinearAxis() { Key = "y_axis", AbsoluteMinimum = y0, AbsoluteMaximum = y1, Position = AxisPosition.Left });
1179+
1180+
model.Axes.Add(new LinearColorAxis { Title = "wrong Placement", Position = AxisPosition.Right, Palette = OxyPalettes.Jet(500), HighColor = OxyColors.Gray, LowColor = OxyColors.Black });
1181+
1182+
var hms = new HeatMapSeries
1183+
{
1184+
X0 = x0,
1185+
X1 = x1,
1186+
Y0 = y0,
1187+
Y1 = y1,
1188+
Data = peaksData,
1189+
XAxisKey = "x_axis",
1190+
YAxisKey = "y_axis"
1191+
};
1192+
model.Series.Add(hms);
1193+
1194+
return model;
1195+
}
1196+
11601197
/// <summary>
11611198
/// Contains example code for https://github.com/oxyplot/oxyplot/issues/42
11621199
/// </summary>

Source/OxyPlot/Axes/Rendering/HorizontalAndVerticalAxisRenderer.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ public override void Render(Axis axis, int pass)
133133
break;
134134
}
135135

136+
switch (axis.Position)
137+
{
138+
case AxisPosition.Left:
139+
case AxisPosition.Top:
140+
titlePosition += axis.AxisDistance;
141+
break;
142+
case AxisPosition.Right:
143+
case AxisPosition.Bottom:
144+
titlePosition -= axis.AxisDistance;
145+
break;
146+
}
147+
136148
if (pass == 0)
137149
{
138150
this.RenderMinorItems(axis, axisPosition);

0 commit comments

Comments
 (0)