简体   繁体   English

c# OxyPlot 为曲线下的图形着色

[英]c# OxyPlot coloring the graph under the curve

Is it possible in OxyPlot to colour the graph under the curve?是否可以在 OxyPlot 中为曲线下的图形着色? And if it is then how?如果是,那又如何? Just like this像这样在此处输入图片说明

This is my source:这是我的来源:

PlotView myPlot = new PlotView();
// Create Plotmodel object          
var myModel = new PlotModel { Title = string.Format("{0}\n\r∫f(x) = ({1}x^3) + ({2}x^2) + ({3}x) + ({4}) = {5} \n\r{6} ", horniMez, koeficienty[3], koeficienty[2], koeficienty[1], koeficienty[0], integral, dolniMez )};
           
myModel.Series.Add(new FunctionSeries(x=>koeficienty[3]*x*x*x+koeficienty[2]*x*x+koeficienty[1]*x+ koeficienty[0], dolniMez, horniMez, 0.1, string.Format( "Funkce: ({0}x^3) + ({1}x^2) + ({2}x) + ({3})", koeficienty[3], koeficienty[2], koeficienty[1], koeficienty[0])));

// Assign PlotModel to PlotView
myPlot.Model = myModel;

//Set up plot for display
myPlot.Dock = System.Windows.Forms.DockStyle.Top;
myPlot.Location = new System.Drawing.Point(0, 0);
myPlot.Size = new System.Drawing.Size(700, 700);
myPlot.TabIndex = 0;
Controls.Add(myPlot);

Thanks for any advice.感谢您的任何建议。

You can use an AreaSeries for this.您可以为此使用 AreaSeries。 An AreaSeries has two lists of points: Points for the upper edge and Points2 for the lower edge of an area. AreaSeries 有两个点列表:用于区域上边缘的点和用于区域下边缘的点 2。 The area in between is filled with a color that you can specify using the Fill property.中间的区域填充有您可以使用 Fill 属性指定的颜色。 If no value is assigned for Points2, you can use this series to fill the area between the the x-axis and the points.如果没有为 Points2 分配值,您可以使用此系列来填充 x 轴和点之间的区域。 You can also combine FunctionSeries with AreaSeries and use the first to calculate the points:您还可以将 FunctionSeries 与 AreaSeries 结合使用,并使用第一个来计算点:

...

FunctionSeries function = new FunctionSeries(x=>koeficienty[3]*x*x*x+koeficienty[2]*x*x+koeficienty[1]*x+ koeficienty[0], dolniMez, horniMez, 0.1, string.Format( "Funkce: ({0}x^3) + ({1}x^2) + ({2}x) + ({3})", koeficienty[3], koeficienty[2], koeficienty[1], koeficienty[0])));

AreaSeries areaSeries = new AreaSeries();
areaSeries.Points.AddRange(functionSeries.Points);
areaSeries.Color = OxyColors.Black;                      // upper line color
areaSeries.Color2 = OxyColors.Black;                     // lower line, i.e. y=0
areaSeries.Fill = OxyColor.FromArgb(64, 255, 228, 181);  // fill color between
areaSeries.StrokeThickness = 1;

myModel.Series.Add(areaSeries);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM