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?
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.