NPlot + Gtk#

Miguel wrote a fantastic Gtk# control for NPlot. The problem is that this tarball is using Gtk#1. To use Gtk# 2 you must to change lib/Makefile and replace gtk-sharp with gtk-sharp-2.0. You can download the fixed tarball here. This is another code example to draw a histogram:


#define GTK

#if GTK

using Gtk;
using NPlot.Gtk;
#endif

using NPlot;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
class X {
  
static public void PlotBars (IPlotSurface2D plot){
    plot.Clear();
    HistogramPlot histogram=
new HistogramPlot();
    
float f=0.35f;
    System.Console.WriteLine(f);
    histogram.BaseWidth=f;
    histogram.Filled=
true;
    histogram.ShowInLegend=
true;
    histogram.Color=System.Drawing.Color.BlueViolet;
    histogram.Pen.Width=
2f;
    histogram.Pen.Alignment=System.Drawing.Drawing2D.PenAlignment.Inset;
    histogram.Pen.DashStyle=System.Drawing.Drawing2D.DashStyle.DashDot;
    
float[] a=new float[10];
    System.Random random=
new System.Random();
    
for (int i=0; i<a.Length; i++) {
      a[i]=random.Next();
    }
    histogram.DataSource=a;
    plot.Add(histogram);
  }
  
static void Main (){
    
#if GTK
    
Application.Init();
    Window w=
new Window("Test");
    w.DeleteEvent+=
delegate {
      Application.Quit();
    };
    NPlot.Gtk.PlotSurface2D plot=
new NPlot.Gtk.PlotSurface2D();
    PlotBars(plot);
    plot.Show();
    w.Add(plot);
    w.ShowAll();
    Application.Run();
    
#else
    
NPlot.PlotSurface2D s=new NPlot.PlotSurface2D();
    Bitmap b=
new Bitmap(10001000);
    Graphics g=Graphics.FromImage(b);
    g.FillRectangle(Brushes.White, 
0010001000);
    Rectangle bounds=
new Rectangle(0010001000);
    PlotTest(s);
    s.Draw(g, bounds);
    b.Save(
"file.png", ImageFormat.Png);
  
#endif
  
}
}

Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.
  • http://www.buysale.ro/anunturi/constanta.html?localitate=magura Man Yeager

    hi, your website looks broken on my iphone 4G, please fix it if you can do it.