如何在 FSharp.Charting 中设置不透明度和线型
how to set opacity and line type in FSharp.Charting
我知道如何在 FSharp.Charting 中控制颜色、字体大小和网格线。但是有没有办法为线条颜色设置不透明度 and/or 例如将线条类型更改为虚线。
#load @"..\..\FSLAB\packages\FsLab\Fslab.fsx"
open FSharp.Charting
open System.Drawing
let rnd = System.Random()
rnd.NextDouble()
let rs = List.init 100 (fun _ -> rnd.NextDouble()-0.5)
let rs = rs |> List.scan (+) 0.
Chart.Line(rs)
.WithYAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
.WithXAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
像这样:
.....
Chart.Line(rs,Name="randomwalk")
.WithYAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
.WithXAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
.ApplyToChart(fun x -> x.Series.["randomwalk"].BorderDashStyle <- System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash)
.ApplyToChart(fun x -> x.Series.["randomwalk"].Color <- Color.FromArgb(127, Color.Red))
会将图表 randomwalk
的线条样式设置为 ChartDashStyle.Dash
并将颜色设置为半透明 Color.Red
。
我知道如何在 FSharp.Charting 中控制颜色、字体大小和网格线。但是有没有办法为线条颜色设置不透明度 and/or 例如将线条类型更改为虚线。
#load @"..\..\FSLAB\packages\FsLab\Fslab.fsx"
open FSharp.Charting
open System.Drawing
let rnd = System.Random()
rnd.NextDouble()
let rs = List.init 100 (fun _ -> rnd.NextDouble()-0.5)
let rs = rs |> List.scan (+) 0.
Chart.Line(rs)
.WithYAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
.WithXAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
像这样:
.....
Chart.Line(rs,Name="randomwalk")
.WithYAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
.WithXAxis(MajorGrid = ChartTypes.Grid(Enabled=true,LineColor=Color.LightGray))
.ApplyToChart(fun x -> x.Series.["randomwalk"].BorderDashStyle <- System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash)
.ApplyToChart(fun x -> x.Series.["randomwalk"].Color <- Color.FromArgb(127, Color.Red))
会将图表 randomwalk
的线条样式设置为 ChartDashStyle.Dash
并将颜色设置为半透明 Color.Red
。