Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Gnuplot.h

Go to the documentation of this file.
00001 // -*- C++ -*- 00002 00003 // PLearn (A C++ Machine Learning Library) 00004 // Copyright (C) 1998 Pascal Vincent 00005 // Copyright (C) 1999-2002 Pascal Vincent, Yoshua Bengio and University of Montreal 00006 // 00007 00008 // Redistribution and use in source and binary forms, with or without 00009 // modification, are permitted provided that the following conditions are met: 00010 // 00011 // 1. Redistributions of source code must retain the above copyright 00012 // notice, this list of conditions and the following disclaimer. 00013 // 00014 // 2. Redistributions in binary form must reproduce the above copyright 00015 // notice, this list of conditions and the following disclaimer in the 00016 // documentation and/or other materials provided with the distribution. 00017 // 00018 // 3. The name of the authors may not be used to endorse or promote 00019 // products derived from this software without specific prior written 00020 // permission. 00021 // 00022 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00023 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00024 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00025 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00026 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00027 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00028 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00029 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00030 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00031 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 // 00033 // This file is part of the PLearn library. For more information on the PLearn 00034 // library, go to the PLearn Web site at www.plearn.org 00035 00036 00037 00038 00039 /* ******************************************************* 00040 * $Id: Gnuplot.h,v 1.10 2004/07/21 16:30:51 chrish42 Exp $ 00041 * AUTHORS: Pascal Vincent & Yoshua Bengio 00042 * This file is part of the PLearn library. 00043 ******************************************************* */ 00044 00045 00048 #ifndef GNUPLOT_INC 00049 #define GNUPLOT_INC 00050 00051 //#include "general.h" 00052 //#include <cstdio> 00053 //#include <fstream> 00054 //#include "pl_io.h" 00055 #include <plearn/math/Mat.h> 00056 #include <plearn/io/TmpFilenames.h> 00057 #include <plearn/base/Array.h> 00058 00059 namespace PLearn { 00060 using namespace std; 00061 00062 00063 class Gnuplot 00064 { 00065 protected: 00066 TmpFilenames tmpfilenames; 00067 FILE* gp_cstream; 00068 PStream tognuplot; 00069 00070 public: 00071 Gnuplot(int max_nb_plot=20); 00072 Gnuplot(const Vec& v1, const string& opt1); 00073 Gnuplot(const Vec& v1, const string& opt1, const Vec& v2, const string& opt2); 00074 Gnuplot(const Vec& v1, const string& opt1, const Vec& v2, const string& opt2, const Vec& v3, const string& opt3); 00075 00076 ~Gnuplot(); 00077 00078 PStream& operator<<(const string& str); 00079 void flush(); 00080 00081 void setxrange(real xmin, real xmax); 00082 void setyrange(real ymin, real ymax); 00083 void setrange(real xmin, real xmax, real ymin, real ymax); 00084 void seteps(const string &filename); 00085 00086 void plot(const Vec& v1, const string& opt1=""); 00087 void plot(const Vec& v1, const string& opt1, const Vec& v2, const string& opt2); 00088 void plot(const Vec& v1, const Vec&v2) { plot(v1,"",v2,""); } 00089 void plot(const Vec& v1, const string& opt1, const Vec& v2, const string& opt2, const Vec& v3, const string& opt3); 00090 void plot(const Vec& v1, const Vec&v2, const Vec& v3) { plot(v1,"",v2,"",v3,""); } 00091 void plot(const Vec& v1, const string& opt1, const Vec& v2, const string& opt2, const Vec& v3, const string& opt3, const Vec& v4, const string& opt4); 00092 void plot(const Vec& v1, const Vec&v2, const Vec& v3, const Vec& v4) { plot(v1,"",v2,"",v3,"",v4,""); } 00093 void plot(const Mat& m1, const string& opt1=""); 00094 void plot(const Mat& m1, const string& opt1, const Mat& m2, const string& opt2); 00095 void plot(const Mat& m1, const string& opt1, const Mat& m2, const string& opt2, const Mat& m3, const string& opt3); 00096 void plot(const Mat& m1, const string& opt1, const Mat& m2, const string& opt2, const Mat& m3, const string& opt3, const Mat& m4, const string& opt4); 00097 void plot(const Mat& m1, const string& opt1, const Mat& m2, const string& opt2, const Mat& m3, const string& opt3, 00098 const Mat& m4, const string& opt4, const Mat& m5, const string& opt5); 00099 void plot(const Mat& m1, const string& opt1, const Mat& m2, const string& opt2, const Mat& m3, const string& opt3, 00100 const Mat& m4, const string& opt4, const Mat& m5, const string& opt5, const Mat& m6, const string& opt6); 00101 00102 // m must have 3 columns, with the 3rd column containing class numbers 00103 // all points (x,y) will be plotted, with a different color and shape for each class 00104 void plotClasses(const Mat& m); 00105 00106 void multiplot(vector<Mat *> &ms, vector <string> &opts); 00107 void plot3d(const Mat &m1, const string &opt1=""); 00108 00109 void plotcdf(Vec feature, const string& title="cdf"); 00110 void plotcdf(const Array<Vec>& vecarray, const Array<string>& titlearray); 00111 void plotdensity(Vec feature, const string& title, int halfwindowsize, string range=""); 00112 void plotdensity(const Array<Vec>& vecarray, const Array<string>& titlearray, int halfwindowsize); 00113 00114 void histoplot(Vec feature, real minval, real maxval, int nbins, bool do_normalize=false, char* title="histogram"); 00115 00116 void histoplot(Vec feature, Vec classnums, real minval, real maxval, int nbins, bool do_normalize=false); 00117 00122 void featureplot(Mat inputs, Vec classnums, char* withwhat="points"); 00123 00124 void featureplot(Mat dataset, char* withwhat="points") 00125 { 00126 featureplot(dataset.subMatColumns(0,dataset.width()-1), 00127 dataset.lastColumn().toVecCopy(), withwhat); 00128 } 00129 00130 // export as postscript file 00131 void export_ps(string psfname, string psoptions="eps color"); 00132 00133 }; 00134 00135 } // end of namespace PLearn 00136 00137 #endif

Generated on Tue Aug 17 15:54:30 2004 for PLearn by doxygen 1.3.7