Two or more plots per Form?

Oystein Bjorke 10 aastat tagasi 0
This discussion was imported from CodePlex

goicox wrote at 2013-06-21 09:07:

Dear OxyPlotUsers

I have been experimenting with OxyPlot under vb.net and trying to reproduce few of the plots shown in the example list. While this has been alright, I was wondering how one could show more than one plot (say 3) per form? And also how to position each plot in the form?

Below is the code I have used to reproduce one of the examples:
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        InitializeComponent()

        Dim Plot As OxyPlot.WindowsForms.Plot = New OxyPlot.WindowsForms.Plot()
        Plot.Dock = DockStyle.Fill
        Plot.Model = New PlotModel("Peaks")

        Dim cs As ContourSeries = New ContourSeries()
        cs.ColumnCoordinates = ArrayHelper.CreateVector(-3, 3, 0.05)
        cs.RowCoordinates = ArrayHelper.CreateVector(-3.1, 3.1, 0.05)
        cs.ContourColors = {OxyColors.SeaGreen, OxyColors.RoyalBlue, OxyColors.IndianRed}
        cs.Data = peaks(cs.ColumnCoordinates, cs.RowCoordinates)
        Plot.Model.Series.Add(cs)

        Me.Controls.Add(Plot)

    End Sub

    Function peaks(ByVal xin() As Double, ByVal yin() As Double) As Double(,)

        Dim ni As Integer = xin.Length
        Dim nj As Integer = yin.Length
        Dim res(ni - 1, nj - 1), x, y As Double
        Dim k As Integer = 0

        For i As Integer = 0 To ni - 1
            x = xin(i)
            For j As Integer = 0 To nj - 1
                y = yin(j)

                res(i, j) = 3 * (1 - x) * (1 - x) * Math.Exp(-(x * x) - (y + 1) * (y + 1)) _
                       - 10 * (x / 5 - x * x * x - y * y * y * y * y) * Math.Exp(-x * x - y * y) _
                       - 1.0 / 3 * Math.Exp(-(x + 1) * (x + 1) - y * y)

                k = k + 1
            Next
        Next
        Return res

    End Function
Thank you in advance, Goicox