How to update a function plot?

Aug 21, 2012 at 12:52 PM


I would like to create plot, which relys on a function rather than on data points. This plot should automatically be updated in case of a change of the x axis. For instance, this should be done when a user zooms out (or in).

Manually, I have done this with text boxes, where you type in xmin and xmax and the graph is updated via data binding. Maybe, it is possible to extend this idea by binding to the minimum and maximum of the x axis. But I don't know how to do this. Has anyone an idea how to tackle this problem?

Aug 21, 2012 at 1:46 PM

Subscribe to the AxisChanged event on the axis. The ActualMaximum and ActualMinimum values are updated before the event is raised, and these values can be used to update the limits of your function series. Then call PlotModel.Refresh(true) (since the plot data was modified) to update the plot. 

Aug 22, 2012 at 7:17 AM

Thank you, for your immediate response. I thnk, your solution works fine in case of a pure C# program. But what I like to have is a C#/WPF solution with MVVM pattern. That is, I have

1.) a model for the function f(x). The evaluation of this function yiels the Points and depends on the limits of x: XMin, XMax.

       public double XMin { get; set; }

       public double XMax { get; set; }

       public IList<DataPoint> Points{  get  {  return evaluatedPoints;  }  }

2.) a view model where OnPropertyChanged of the Points and the changed limit is raised.

       public IList<DataPoint> Points { get { return model.Points; } }

       public double XMax // same for XMin


           get { return model.XMax; }



               model.XMax = value;





3.) a WPF view where the axis properties are modified. With respect to XMax we have for instance


               <oxy:LinearAxis Position="Bottom">


                       <Binding Mode="TwoWay"


                               Source="{StaticResource viewModel}"

                               UpdateSourceTrigger="PropertyChanged" />





The problem is that there is no dependency property for ActualMaximum and ActualMinimum. Of course, I could implement this. But I don't like this approach, because than I am modifying your library. As a consequence I have to do this modification for all future versions.

To this end, I would like to ask you, if you can do this?

Aug 24, 2012 at 7:12 AM

I think it could be possible to add an AxisChanged routed event on the OxyPlot.Wpf.LinearAxis. This could pass the events from the OxyPlot.LinearAxis.

It should also be possible to make some read-only dependency properties for ActualMaximum/ActualMinimum, which may get change notifications every time the plot is changed (e.g. panned, zoomed or data changed).

Aug 24, 2012 at 9:00 AM

Hi objo, that would be cool! I am looking forward to this feature!