VB.NET中的矩阵列绘图
我有一个矩阵,它的维数在代码执行之前是未知的。它可以是任何尺寸。我想用不同的颜色为每一列绘制点。 假设第1列使用一种颜色,第2列使用另一种颜色,依此类推 我有这个代码,但它用相同的颜色绘制所有的点。有什么想法吗VB.NET中的矩阵列绘图,vb.net,matrix,charts,data-visualization,Vb.net,Matrix,Charts,Data Visualization,我有一个矩阵,它的维数在代码执行之前是未知的。它可以是任何尺寸。我想用不同的颜色为每一列绘制点。 假设第1列使用一种颜色,第2列使用另一种颜色,依此类推 我有这个代码,但它用相同的颜色绘制所有的点。有什么想法吗 Dim s1 As New System.Windows.Forms.DataVisualization.Charting.Series s1.ChartType = SeriesChartType.Point s1.Name = "Clusters" For h = 1 To Nu
Dim s1 As New System.Windows.Forms.DataVisualization.Charting.Series
s1.ChartType = SeriesChartType.Point
s1.Name = "Clusters"
For h = 1 To Num_clusters 'number of columns
For ss = 1 To jobs 'maximum row size
If clusters(ss, h) <> 0 Then 'depending of code execution, it could be rows empty, so checking only non-empty rows
s1.Points.AddXY(x(clusters(ss, h)), y(clusters(ss, h))) 'Just taking the X-Y components of the data
s1.Color = Color.FromArgb(h + 100, 162, 178) 'Here trying to make all columns different colours with the h+100 (h=column index)
End If
Next 'Row
'after reading the rows from this column, add the points with a colour
'Chart1.Series.Add(s1) 'If I run this here an error happens and it doesn't plot
Next 'Column
'If I add chart series here would plot all with the same colour
但是我不知道自动创建新系列s
和h
的正确语法是什么
如何解决此问题?您正在将所有点添加到一个系列中。我认为您需要为每一列创建不同的系列。每个系列可以指定不同的颜色。是的,这就是我的想法,但我找不到一种方法来定义无限系列。但是我已经用s1.Points(jj.Color)解决了这个问题,并给jj计数器加了一些条件
For h = 1 To Num_clusters 'number of columns
Dim (s & h) As New Series 'Trying to automatically create new series: s1,s2,...,sNum_clusters
For ss = 1 To jobs 'maximum row size
'code
'
'
'
Next 'rows
'Chart1.Series.Add(s & h)
Next 'column