Question Contour plot

Danielss

Member
Joined
Mar 22, 2010
Messages
20
Programming Experience
1-3
hi everyone, i've tried googling this and have checked out a lot of VB.net graphing addons but none of them seem to have the ability to draw a contour plot.
I have an array that i want to display as a contour plot. Can anyone offer advice how i can accomplish this?
 
ok, I've already incorporated Zedplot into my program for other charts. I thought i read somewhere that it didn't have a contour plot. I obviously fail at life. Thank you for your help!
 
I have managed to use zedgraph fine, plotting xy-line graphs of a number of arrays.
But I don't see how I can give my value for an xy position to this contour graph. Can anyone help me out with a very basic example?

Say i wanted a very basic grid of:

1 1 1
1 2 1
1 1 1

How would i give zedplot these values?
 
Ok, in case anyone else stumbles over this and is after a quick answer.
This is one of the methods i've found effective. This works fine as long as your array contains less than ~20000 values. Anything much more than that and i find the graph fails to display- i'm just finishing off a better method and hope this will display over 20000 values, in the mean time you can live with this.

In the example the graph on the form is called 'zg3' and basically a box gets drawn for each array value (4 points are generated and a line is drawn from a point to the next one in order and then back to the first point) then the box is filled with a colour based on the value held in that point of the array.

VB.NET:
Imports ZedGraph

Public Class geometrygraph

    Private Sub contourplot_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call CreateGraph_Contour(zg3)
    End Sub


    Sub CreateGraph_Contour(ByVal zgc As ZedGraphControl)
        Dim myPane As GraphPane = zgc.GraphPane

        myPane.Title.Text = "Geometry Test"
        myPane.XAxis.Title.Text = "X Number"
        myPane.YAxis.Title.Text = "Y Number"
        Dim i As Integer = 0
        Dim j As Integer = 0
        Dim k As Integer = 0
        Dim myCurve As LineItem
        ' Draws boxes around each array point

        For j = 0 To UBound(geometry.geomArray, 2)
            For i = 0 To UBound(geometry.geomArray, 1)
                Dim list As New PointPairList()
                Dim x As Integer, y As Integer

                x = i
                y = j
                list.Add(x, y)
                x = i + 1
                y = j
                list.Add(x, y)
                x = i + 1
                y = j + 1
                list.Add(x, y)
                x = i
                y = j + 1
                list.Add(x, y)

                list.Add(list(0)) ' duplicate the first point at the end to complete the circle

                ' Add a curve with a suitable level, no symbols
                Dim myCurve2 As LineItem = myPane.AddCurve("Level=" + k.ToString(), list, Color.Black, SymbolType.None)


                myCurve2.Line.IsSmooth = False ' Smooth out the contours a little

                ' Fill the boxes with colour depending on array contents

                myCurve = myPane.CurveList(k)
                If geometry.geomArray(i, j) = 1 Then
                    myCurve.Line.Fill = New Fill(Color.Red, Color.Red, 45.0F)
                End If
                If geometry.geomArray(i, j) = 2 Then
                    myCurve.Line.Fill = New Fill(Color.Blue, Color.Blue, 45.0F)
                End If
                If geometry.geomArray(i, j) = 3 Then
                    myCurve.Line.Fill = New Fill(Color.Yellow, Color.Yellow, 45.0F)
                End If

                k += 1

                End If
            Next i

        Next j

        myPane.Legend.IsVisible = False
        myPane.Chart.Fill = New Fill(Color.White, Color.White, 45.0F)
        myPane.Fill = New Fill(Color.White, Color.White, 45.0F)

        ' Manually set the axis ranges
        myPane.XAxis.Scale.Min = 0
        myPane.XAxis.Scale.Max = UBound(geometry.geomArray, 1) + 1
        myPane.YAxis.Scale.Min = 0
        myPane.YAxis.Scale.Max = UBound(geometry.geomArray, 2) + 1
        zgc.AxisChange()
    End Sub


End Class
 
ok, rather than post each new iteration up i'm going to wait until i've found something that i think is optimal. If i forget to post it here when i'm done and somebody needs it (in weeks/ months/ years) then reply to this thread and i should come along and help.
 
Help

Hello
I would need your help now, since I have to do such a 2D contour plot, and I just started programming with visual basic 2 weeks ago, but I need it for my master thesis. So far I got my things to work, (Fourier Transform, simple plots) but with this contour plots I reached my limits.
I would be really happy if you could help me
 
well, i had completely forgotten i'd done this... Have you got your previous plots working with Zedgraph of something else?
 
So far, I just used a picturebox and the commands,
Interferogram_temp.Line -(k, temp_interfer(k)), QBColor(9)

what means, that I did not work with ZedGraph so far.
I looked ad the homepage which is cited above and something like that would be good.

on the other homepage there several zedgraph files which confuse me a little, what do i really need

I tried to implement you code just to be able to play around but there you allread import zedgraph . what would i have to do such that this would work to get started?
 
Yes, I have similar problem. I want to generate a contour map consisting 9 x 9 matrix, and want to generate it in real time (in iteration lopping). Is there any effective way in vb.net?
 
Yes, I have similar problem. I want to generate a contour map consisting 9 x 9 matrix, and want to generate it in real time (in iteration lopping). Is there any effective way in vb.net?

If you mean that you want the contour plot to keep changing then this is beyond my knowledge of zedplot but i think you'd need to have some kind of redraw function in there, i'm sure there must be a way to make the controls on a form redraw, try searching. Otherwise, if it would suit your needs you could certainly use the code i've posted above and create a new plot on a new form each time you want it to update
 
Back
Top