I am using NPlot to display contour charts using PlotSurface2D. When I reverse the Y axis order the chart does not display correctly.
My data goes from 0,0 to 10,10 (11 rows and 11 columns). I want data point 0,0 to appear in the upper left hand corner of the plot. The default has Y values increasing so 0,0 is in the lower left.
When I set YAxis1.Reversed I get the desired effect of the numbers on the Y axis (0 is at the top and 10 is at the bottom). But the data is plotted incorrectly. Data from row 0 is plotted on row 1, etc.
Here is a code fragment for how I am plotting the data:
int row = 10;
int col = 10;
double[,] map = new double[row, col];
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
map[i, j] = i;
}
}
this.myPlotSurface.Clear();
myPlotSurface.Title = "Grid Survey";
NPlot.ImagePlot ip = new NPlot.ImagePlot(map, 0, 1, 0, 1);
ip.Gradient = new NPlot.LinearGradient(Color.Blue, Color.Red);
ip.Center = false;
myPlotSurface.Add(ip);
// Reverse Y axis so grid matches physical space
myPlotSurface.YAxis1.Reversed = true;
NPlot.Grid grid = new NPlot.Grid();
grid.HorizontalGridType = NPlot.Grid.GridType.Fine;
grid.VerticalGridType = NPlot.Grid.GridType.Fine;
myPlotSurface.Add(grid);
myPlotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
myPlotSurface.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.MouseWheelZoom());
myPlotSurface.Refresh();
Screenshot of bug
I made a tentative fix by changing ImagePlot.cs as follows:
public void Draw( Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis )
{
....
// BRENTB - 2009/02/12
// Fix for bug when [XY]Axis1.Reversed == true
// See artifact 2590560 filed against NPlot for details
//
//if ( !hPositive )
//{
// wY += yStep_;
//}
//if (!wPositive )
//{
// wX += xStep_;
//}
....
}
reproduced, looking into.