簡體   English   中英

c# OxyPlot 為曲線下的圖形着色

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

是否可以在 OxyPlot 中為曲線下的圖形着色? 如果是,那又如何? 像這樣在此處輸入圖片說明

這是我的來源:

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);

感謝您的任何建議。

您可以為此使用 AreaSeries。 AreaSeries 有兩個點列表:用於區域上邊緣的點和用於區域下邊緣的點 2。 中間的區域填充有您可以使用 Fill 屬性指定的顏色。 如果沒有為 Points2 分配值,您可以使用此系列來填充 x 軸和點之間的區域。 您還可以將 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