DateTimeAxis with IntervalType == DateTimeIntervalType.Minutes

May 6, 2013 at 8:33 AM

I want to display measurement data, where measurements were made every full minute (60 seconds), so I'm using DateTimeAxis with IntervalType == DateTimeIntervalType.Minutes on X axis. I'm using DateTimeAxis.ToDouble() to calculate x-coordinate and I obtain correct point series.

However, I was expecting ticks on the X axis to appear every full minute, but the actual distance between ticks is one minute +- a few seconds (see Example screen capture.).

Is there a way to have tick's distance equal to exactly 1 minute?

    public static PlotModel DateTimeAxisExample()
        var plotModel1 = new PlotModel();
        var linearAxis1 = new LinearAxis();
        linearAxis1.MinorGridlineStyle = LineStyle.Dot;

    var dateTimeAxis1 = new DateTimeAxis();
        dateTimeAxis1.IntervalType = DateTimeIntervalType.Minutes;
        dateTimeAxis1.EndPosition = 0;
        dateTimeAxis1.StartPosition = 1;
        dateTimeAxis1.StringFormat = "hh:mm:ss";

        return plotModel1;
May 6, 2013 at 9:10 AM
I think there is a bug in the DateTimeAxis. Maybe this is related to double precision accuracy. I am adding a new issue:
May 7, 2013 at 12:58 PM
Edited May 7, 2013 at 12:59 PM

I've found that, in this case, in class: OxyPlot.Axes.Axis, in method: protected static IList<double> CreateTickValues(double min, double max, double step). commenting line: x = x.RemoveNoise(); solves a problem.

Good code, and a good library, by the way.
Jun 8, 2013 at 9:57 AM
Thanks for the solution, I will keep this in mind when looking into the DateTimeAxis again! I think I need to add more tests before I remove the 'RemoveNoise' line.
Jul 4, 2013 at 1:31 PM
I have another similar problem, sometimes at the minute or seconde scale, some major ticks doesn't appears


I use Nugget, so i wonder if the solution proposed by swiszcz is available in the lastest version.

Thank you for your answer, your work is awesome,

Jul 4, 2013 at 1:45 PM
Edited Jul 4, 2013 at 1:47 PM
Hi Raphay,

Although commenting line: x = x.RemoveNoise(); solves a my problem, i have no idea how does it influence the rest of a code (and it may as it is in a base class). So I just made a private fork of OxyPlot.

Best regards