views:

2513

answers:

7
+4  Q: 

Plotting with C#

C# seems to show some promise for scientific computing, but I found very little about one plotting 2D graphs, which is very important both for science student and scientists.

Is there a reliable, free, way to create publication quality 2D plot with C# ? And the capacity to save to several formats (png, eps, ...). Something similar to Python's matplotlib ?

A: 

Well theres GDI+, which is a pretty standard 2D library. (Add a reference to System.Graphics to use GDI+) But for the "publication quality" that you ask for, I'd suggest looking at some of the graphing articles at a site like http://www.codeproject.com to get started.

Neil N
Well, yeah, obviously you could program your own charting API. That doesn't seem to really answer this question at all.
BobbyShaftoe
+1  A: 

I starting using the new ASP.NET Chart control a few days ago, and it's absolutely amazing in its capabilities.

Here is the link.

EDIT: This is obviously only if you using ASP.NET. Not sure about WinForms.

BBetances
you didn't include the link
ChrisW
It was on there before the edit I think.
BobbyShaftoe
Info can be found at: http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx
Cerebrus
sorry i think i edited it out. thanks C.
BBetances
A: 

NPlot is a pretty good simple open source 2D plotting API. Unfortunately, the web site is down. I don't know if this is just temporary or not. I haven't heard of any bad news. It may come back up.

http://www.nplot.com

Here is an article describing it:

http://aspnet.4guysfromrolla.com/articles/072507-1.aspx

The previous article uses VB.NET, but obviously this will work with C#.

Again, not sure why nplot's site is not currently working but it is a somewhat popular plotting API that I've used in the past. I post it for your information and in case of the likely event nplot will be back up soon. :)

Edit:

Thanks to a Hosam Aly, it looks like the SourceForge project can still be accessed here:

http://sourceforge.net/projects/nplot

BobbyShaftoe
You can still open the project's page in SourceForge:http://sourceforge.net/projects/nplot
Hosam Aly
+4  A: 

ZedGraph is a good choice.

Bob Nadler
I've also had success with ZedGraph for smaller applications
Factor Mystic
ZedGraph is really good for smaller applications.
dalle
Is it me, or is ZedGraph ugly? Am I missing the options that make it look nice?
Alex Baranosky
+1 for contour plots
ccook
+2  A: 

See Samples Environment for Microsoft Chart Controls:

The samples environment for Microsoft Chart Controls for .NET Framework contains over 200 samples for both ASP.NET and Windows Forms. The samples cover every major feature in Chart Controls for .NET Framework. They enable you to see the Chart controls in action as well as use the code as templates for your own web and windows applications.

Seems to be more business oriented, but may be of some value to science students and scientists.

gimel
Be sure to check the doenloads tab for the sample code
Henk Holterman
A: 

FWIW, you probably want to look at F# instead of C# in the context of technical computing because F# is specifically designed for that purpose. However, I developed my own commercial plotting library because I was not satisfied with anything freely available on .NET.

Jon Harrop
A: 

gnuplot is an actively maintained program widely used in the scientific community. Normally plots are generated from data files which you can write out in your C# program, but it is also possible to call the gnuplot executable from C# and display the generated image in a C# picture box.

Danvil