c# - c# OxyPlot 为曲线下的图形着色
问题描述
是否可以在 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 有两个点列表:上边缘的点和区域下边缘的 Points2。中间的区域填充有您可以使用 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);
推荐阅读
- validation - 如何将应用验证转换为返回 MonadThrow?
- python - 如何在 Matplotlib 中使用坐标?
- flutter - 如何从同时悬停的多个小部件中获取信息?
- python - 查询集外键模型
- php - 如何使嵌入 iframe 的 YouTube 播放器正常工作而不阻止 Chrome 中的页面加载?
- c# - 为什么在包含 foreach 循环之后我得到了?
- react-native - 使用新坐标更新 react-native-map
- linux - dpkg“处理触发器时发现循环”libc-bin
- ios - 调整启动屏幕故事板以启动具有固定大小的图像
- java - 当数字达到小数点后 3 位时如何停止 while 循环?