2

Is it possible to draw the area of a certain integral in Oxyplot?

With the MathNet.Numerics library it is possible to calculate these integrals but I am wondering if I am able to draw it in my plot?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
binaryBigInt
  • 1,526
  • 2
  • 18
  • 44

1 Answers1

3

I am no expert in the matter, but I may have found something helpfull for you... Take a look at AreaSeries. I think this is what you need.

Example:

        var model = new PlotModel { Title = "AreaSeries" };

        var series = new AreaSeries { Title = "integral" };
        for (double x = -10; x <= 10; x++)
        {
            series.Points.Add(new DataPoint(x, (-1 * (x * x) + 50)));
        }

        model.Series.Add(series);

Then you set the model to your PlotView.Model and you should see a plot similar at what you posted in the comments above.

I hope this works for you.

----- EDIT (because of comment in the answer) -----

It turns out that you actually can do what you asked in the comments. You just need to fill AreaSeries.Points2 with the points you want to restrict your Area. For example, in my previous sample add inside the for the following line

series.Points2.Add(new DataPoint(x, x));

Then you will have the area defined by two lines: y = -x^2 + 50 and y = x. You can even set the second line transparent.

Complete Example:

        var model = new PlotModel { Title = "AreaSeries" };

        var series = new AreaSeries { Title = "series" };
        for (double x = -10; x <= 10; x++)
        {
            series.Points.Add(new DataPoint(x, (-1 * (x * x) + 50)));
            series.Points2.Add(new DataPoint(x, x));
        }
        series.Color2 = OxyColors.Transparent;

        model.Series.Add(series);

        plotView.Model = model;

Now you just have to add the formulas that you need, and it should show a similar graph to the one you put in your comment.

Vic
  • 189
  • 1
  • 15
  • Although it does not work for all kinds of functions: http://www.pic-upload.de/view-28746614/integral.png.html – binaryBigInt Nov 02 '15 at 14:20
  • That's right. That last graph is a little more complicated... Can you put the equation of the curve? I will think about it and see if I can come with any trick – Vic Nov 05 '15 at 07:30
  • I just updated the answer. Take a look. It turns out to be quite simple. Just add the second series to "series.Points2" and you are ready to go! – Vic Nov 06 '15 at 15:01