【发布时间】:2013-09-12 19:29:13
【问题描述】:
如果点数 > 100,我想永久更改线条颜色;我的意思是我想在图表上看到数据大于 100 的红线,数据小于 100 的绿线。我该怎么做?
如果可能的话,我想要矩形内数据范围的红线。
【问题讨论】:
如果点数 > 100,我想永久更改线条颜色;我的意思是我想在图表上看到数据大于 100 的红线,数据小于 100 的绿线。我该怎么做?
如果可能的话,我想要矩形内数据范围的红线。
【问题讨论】:
查看Gradient-By-Value 示例图表。该图表使用第三个坐标 (Z) 来指示点的颜色,通过设置:
curve.Symbol.Fill.Type = FillType.GradientByZ;
同样,您可以使用GradientByY 指示应使用y 轴值。但是,如果RangeMin 和RangeMax 相等,则似乎将错误的颜色应用于整个图表,因此您需要使它们相差一个相对较小的值。
curve.Symbol.Fill = new Fill( Color.Green, Color.Red );
curve.Symbol.Fill.Type = FillType.GradientByY;
curve.Symbol.Fill.RangeMin = 100 - 1e-3;
curve.Symbol.Fill.RangeMax = 100;
【讨论】:
curve.Line.Fill而不是curve.Symbol.Fill吗?我看到它在绘图时使用它,尽管我认为它不能正确渲染分割线。
我认为改变曲线中几个点的颜色是不可能的,但是你可以使用 Zedgraph 的BoxObject 改变一个区域的颜色。
尝试以下方法:
private void drawRegion()
{
GraphPane pane = zedGraphControl1.GraphPane;
BoxObj box = new BoxObj(0, 20, 500, 10,Color.Empty, Color.LightYellow);
box.Location.CoordinateFrame = CoordType.AxisXYScale;
box.Location.AlignH = AlignH.Left;
box.Location.AlignV = AlignV.Top;
// place the box behind the axis items, so the grid is drawn on top of it
box.ZOrder = ZOrder.E_BehindCurves;
pane.GraphObjList.Add(box);
// Add Region text inside the box
TextObj myText = new TextObj("Threshold limit", 100, 15);
myText.Location.CoordinateFrame = CoordType.AxisXYScale;
myText.Location.AlignH = AlignH.Right;
myText.Location.AlignV = AlignV.Center;
myText.FontSpec.IsItalic = true;
myText.FontSpec.FontColor = Color.Red;
myText.FontSpec.Fill.IsVisible = false;
myText.FontSpec.Border.IsVisible = false;
pane.GraphObjList.Add(myText);
zedGraphControl1.Refresh();
}
【讨论】: