AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Syed Rizwan Muhammad Rizvi
Expertise
I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.

Experience
Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > 2D contour plot using vb.net

Topic: VB.NET



Expert: Syed Rizwan Muhammad Rizvi
Date: 1/17/2008
Subject: 2D contour plot using vb.net

Question
QUESTION: I would like to write 2D contour plot routine in vb.net
Lets say you have four values of a function f(x,y) at four corners of a square. How do you fill the square to represent variation of f(x,y) in vb.net?

ANSWER: can you send an image of what you want to plot with sample values on each corner?

---------- FOLLOW-UP ----------

QUESTION: I am not interested in one particular image. To put it more generally, I have an array of values f(i,j) over a regular grid. I would like to draw filled contour plots.

ANSWER: Hi,

http://msdn2.microsoft.com/en-us/library/system.drawing.graphics_methods.aspx

The above link will take you to the generic VB.net 2D drawing API.

After finding the API that suits your need you can come back to me and we can discuss it in greater detail.

Regards,
Riz

---------- FOLLOW-UP ----------

QUESTION: I have already coded some "drawing" using GDI+ e.g using code such as

e.Graphics.DrawLines(bluePen, coor_init_pts)

I have two problems -
1. I do not know a good way to "fill" colors according to contour variable
2. I have drawn this on a panel and I do not know how to generate images (like jpg) from drawing on a panel.

I have tried googling but I do not understand it well adn I didn't find a "complete" code. Take a look at the following outline

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

...
e.Graphics.DrawLine(BlackPen, MeshOrigin(1), yg_min + 10, MeshOrigin(1), yg_max - 10)
...
end sub

Now after I have done such drawing, I want to do two things-
1. Save image of my drawing
2. Draw contour line as per contour variable value at "mesh points" - defined within the code - think of pair of integers (i,j) and values f(i,j)
3. Fill contours with colors depending on contour value.

I can't even do 1, and would like to know about 2 and 3 as well.


Answer
1. use img = new Image: g = new Graphics.FromImage(img): 'Do funky graphics stuff here: img.Save(...).

2. Drawing lines doesn't create a closed region. I ask you to investigate DrawRegion or DrawPolygon to create and merge complex Regions/Meshes then it becomes really easy to fill them as well.

3. See above.

Regards,
Riz

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.