VB.Net 创建箱线图
VB.Net Box Plot Creation
我很难理解 boxplots 的工作原理 VB.Net。以下是有效的,但它绘制了 boxplot 和条形图。我只想要箱线图。我发现您可以禁用违规系列以将它们从图表中删除,但这似乎是错误的方法...
当前剧情
我的代码有什么问题?同样,我只想要箱线图。
Dim yVal As Double() = {55.62, 45.54, 73.45, 9.73, 88.42, 45.9, 63.6, 85.1, 67.2, 23.6}
Dim yVal2 As Double() = {35.62, 25.54, 43.45, 23.73, 43.42, 12.9, 23.6, 65.1, 54.2, 41.6}
Chart1.Series.Clear()
Chart1.Series.Add("BoxPlotSeries")
Chart1.Series.Add("1")
Chart1.Series("1").Points.DataBindY(yVal)
Chart1.Series.Add("2")
Chart1.Series("2").Points.DataBindY(yVal2)
Chart1.Series("BoxPlotSeries").ChartType = SeriesChartType.BoxPlot
Chart1.Series("BoxPlotSeries")("BoxPlotSeries") = "1;2"
Chart1.Series("BoxPlotSeries")("BoxPlotWhiskerPercentile") = "15"
Chart1.Series("BoxPlotSeries")("BoxPlotShowAverage") = "true"
Chart1.Series("BoxPlotSeries")("BoxPlotShowMedian") = "true"
Chart1.Series("BoxPlotSeries")("BoxPlotShowUnusualValues") = "true"
禁用那些系列
Chart1.Series("1").Enabled = False
Chart1.Series("2").Enabled = False
也许你不喜欢这些属性的custom properties of the series work. I don't either! But it seems there's no way around indexing them by string name (and setting the values as strings, even if they are boolean or numeric, as you saw). Here is a complete list。
我会在创建它们的范围之外拥有对系列的对象引用。然后您可以稍后根据需要操作它们(即添加/更改数据),而无需使用字符串名称索引图表的 Series 集合。这可能会有所缓解
Private boxPlotSeries As Series
Private series1 As Series
Private series2 As Series
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim yVal As Double() = {55.62, 45.54, 73.45, 9.73, 88.42, 45.9, 63.6, 85.1, 67.2, 23.6}
Dim yVal2 As Double() = {35.62, 25.54, 43.45, 23.73, 43.42, 12.9, 23.6, 65.1, 54.2, 41.6}
Chart1.Series.Clear()
boxPlotSeries = New Series() With {
.Name = "BoxPlotSeries",
.ChartType = SeriesChartType.BoxPlot}
boxPlotSeries("BoxPlotSeries") = "1;2"
boxPlotSeries("BoxPlotWhiskerPercentile") = "15"
boxPlotSeries("BoxPlotShowAverage") = "True"
boxPlotSeries("BoxPlotShowMedian") = "True"
boxPlotSeries("BoxPlotShowUnusualValues") = "True"
series1 = New Series() With {
.Name = "1",
.Enabled = False}
series1.Points.DataBindY(yVal)
series2 = New Series() With {
.Name = "2",
.Enabled = False}
series2.Points.DataBindY(yVal2)
Chart1.Series.Add(boxPlotSeries)
Chart1.Series.Add(series1)
Chart1.Series.Add(series2)
End Sub
我很难理解 boxplots 的工作原理 VB.Net。以下是有效的,但它绘制了 boxplot 和条形图。我只想要箱线图。我发现您可以禁用违规系列以将它们从图表中删除,但这似乎是错误的方法...
当前剧情
我的代码有什么问题?同样,我只想要箱线图。
Dim yVal As Double() = {55.62, 45.54, 73.45, 9.73, 88.42, 45.9, 63.6, 85.1, 67.2, 23.6}
Dim yVal2 As Double() = {35.62, 25.54, 43.45, 23.73, 43.42, 12.9, 23.6, 65.1, 54.2, 41.6}
Chart1.Series.Clear()
Chart1.Series.Add("BoxPlotSeries")
Chart1.Series.Add("1")
Chart1.Series("1").Points.DataBindY(yVal)
Chart1.Series.Add("2")
Chart1.Series("2").Points.DataBindY(yVal2)
Chart1.Series("BoxPlotSeries").ChartType = SeriesChartType.BoxPlot
Chart1.Series("BoxPlotSeries")("BoxPlotSeries") = "1;2"
Chart1.Series("BoxPlotSeries")("BoxPlotWhiskerPercentile") = "15"
Chart1.Series("BoxPlotSeries")("BoxPlotShowAverage") = "true"
Chart1.Series("BoxPlotSeries")("BoxPlotShowMedian") = "true"
Chart1.Series("BoxPlotSeries")("BoxPlotShowUnusualValues") = "true"
禁用那些系列
Chart1.Series("1").Enabled = False
Chart1.Series("2").Enabled = False
也许你不喜欢这些属性的custom properties of the series work. I don't either! But it seems there's no way around indexing them by string name (and setting the values as strings, even if they are boolean or numeric, as you saw). Here is a complete list。
我会在创建它们的范围之外拥有对系列的对象引用。然后您可以稍后根据需要操作它们(即添加/更改数据),而无需使用字符串名称索引图表的 Series 集合。这可能会有所缓解
Private boxPlotSeries As Series
Private series1 As Series
Private series2 As Series
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim yVal As Double() = {55.62, 45.54, 73.45, 9.73, 88.42, 45.9, 63.6, 85.1, 67.2, 23.6}
Dim yVal2 As Double() = {35.62, 25.54, 43.45, 23.73, 43.42, 12.9, 23.6, 65.1, 54.2, 41.6}
Chart1.Series.Clear()
boxPlotSeries = New Series() With {
.Name = "BoxPlotSeries",
.ChartType = SeriesChartType.BoxPlot}
boxPlotSeries("BoxPlotSeries") = "1;2"
boxPlotSeries("BoxPlotWhiskerPercentile") = "15"
boxPlotSeries("BoxPlotShowAverage") = "True"
boxPlotSeries("BoxPlotShowMedian") = "True"
boxPlotSeries("BoxPlotShowUnusualValues") = "True"
series1 = New Series() With {
.Name = "1",
.Enabled = False}
series1.Points.DataBindY(yVal)
series2 = New Series() With {
.Name = "2",
.Enabled = False}
series2.Points.DataBindY(yVal2)
Chart1.Series.Add(boxPlotSeries)
Chart1.Series.Add(series1)
Chart1.Series.Add(series2)
End Sub