簡體   English   中英

ZedGraph不同的線條顏色

[英]ZedGraph different line colors

如果點> 100,我想永久改變線條顏色; 我的意思是我想看到數據圖上的紅線大於100而數據的綠色小於100.我怎么能這樣做?

在此輸入圖像描述

如果可能的話,我希望矩形內的數據范圍有紅線。

查看Gradient-By-Value示例圖表。 該圖表使用第三個坐標(Z)來指示點的顏色,方法是:

curve.Symbol.Fill.Type = FillType.GradientByZ;

同樣,您可以使用GradientByY指示應使用y軸值。 但是,如果RangeMinRangeMax相等,則錯誤的顏色將應用於整個圖表,因此您需要使它們相差較小的值。

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;

我不認為可以改變曲線中幾個點的顏色,但是你可以使用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();
    }

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM