从文本文件中绘制XY图

时间:2016-08-12 11:38:37

标签: vb.net csv plot text-files

我想从一个在Fortran中生成的文件中绘制一个简单的XY图(图表类型=行),其中包含VB.net 2015图表中的多个系列。文件内容如下:

1,         500.00    ,         25.607    ,        5.12137E-02
2,         502.50    ,         25.479    ,        5.07049E-02
3,         505.01    ,         25.353    ,        5.02036E-02
4,         507.51    ,         25.228    ,        4.97097E-02

我想将前两列作为X轴值,其余列作为Y轴。 这是我到目前为止所做的:

  Private Sub field_result_Click(sender As Object, e As EventArgs) Handles field_result.Click    
result = "C:\Users\sep\Documents\Visual Studio 2015\Projects\sea electrod-pipe sample\sea electrod-pipe sample\bin\Debug\fort.11"
     Dim s As Stream = New FileStream(result, FileMode.Open,FileAccess.Read)
        Dim sr As StreamReader = New StreamReader(s)
        Dim str As String
        Dim i As Integer = 0
        sr.ReadLine()
        Do While Not sr.EndOfStream

            str = sr.ReadLine
            c(0) = " "
            sarr = str.Split(c, StringSplitOptions.RemoveEmptyEntries)

        Loop

        Chart1.Series.Add("field").ChartType = Charting.SeriesChartType.Line
        Chart1.Series("field").XValueType = Charting.ChartValueType.Int64
        Chart1.Series("field").XAxisType = Charting.AxisType.Primary

        Chart1.Series("field").YValueType = Charting.ChartValueType.Int64
        Chart1.Series("field").YAxisType = Charting.AxisType.Primary
        Chart1.Series("field").Points.addXY(sarr(1), sarr(3))

    End Sub

0 个答案:

没有答案