![]() |
Object-oriented Scientific Computing Library: Version 0.910
|
00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006-2012, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_GRAPH_H 00024 #define O2SCL_GRAPH_H 00025 00026 #include <string> 00027 #include <Gtypes.h> 00028 #include <TApplication.h> 00029 #include <TArrow.h> 00030 #include <TAxis.h> 00031 #include <TBox.h> 00032 #include <TCanvas.h> 00033 #include <TColor.h> 00034 #include <TF1.h> 00035 #include <TGraph.h> 00036 #include <TGraphErrors.h> 00037 #include <TGaxis.h> 00038 #include <TH1.h> 00039 #include <TH2.h> 00040 #include <TLatex.h> 00041 #include <TLegend.h> 00042 #include <TLine.h> 00043 #include <TList.h> 00044 #include <TMarker.h> 00045 #include <TObjArray.h> 00046 #include <TROOT.h> 00047 #include <TStyle.h> 00048 #include <TPolyLine.h> 00049 00050 #include <o2scl/constants.h> 00051 #include <o2scl/table_units.h> 00052 00053 /** \file graph.h 00054 \brief Experimental functions for use with Root 00055 00056 All of the functions in \ref graph.h are documented in 00057 the \ref o2scl_graph namespace. 00058 */ 00059 00060 /** \brief Namespace for experimental functions for use with Root 00061 00062 This namespace contains several functions, defined in graph.cpp, 00063 which simplify plotting with Root. They require that the Root 00064 libraries have been installed and are not compiled in with the 00065 normal \o2 libraries. Some of the example plots created for 00066 the documentation are based on these functions. 00067 */ 00068 namespace o2scl_graph { 00069 00070 /** \brief Draw a pretty arrow from (x1,y1) to (x2,y2) 00071 00072 The parameter \c size determines the size of the head relative 00073 to the size of the arrow, \c size2 determines the position of 00074 the niche (1.0 is no niche), and alpha1 determines the angle of 00075 the head relative to the line (default is about 20 degrees). 00076 */ 00077 void arrow(double x1, double y1, double x2, double y2, 00078 TLine *&line, TPolyLine *&poly, 00079 double size=0.1, double size2=0.8, 00080 double alpha1=0.35); 00081 00082 /** \brief Make a canvas and pad 00083 00084 The CanvasName is the default output filename for graphs and 00085 macros also. The PadName is the name that comes up when you 00086 right-click on the pad. When making .eps files, the Title field 00087 is set to "CanvasName.eps: Windowname". This Title field is the 00088 title that appears, e.g., in a ghostview window. The x-axis 00089 limits are given by \c lleft and \c lright and the y-axis limits 00090 are given in \c lbottom and \c ltop. The upper left corner of 00091 the canvas window is at <tt>(left,top)</tt> and the lower right 00092 corner is <tt>(right,bottom)</tt>. The parameters \c logx and \c 00093 logy determine whether or not the x- or y-axes are logarithmic 00094 instead of linear (the default). The canvas and pad objects 00095 are created using \c new, and the histogram object \c th1 00096 is created with TPad::DrawFrame(). 00097 */ 00098 int new_graph(TCanvas *&c1, TPad *&p1, TH1 *&th1, std::string CanvasName, 00099 std::string WindowName, std::string PadName, 00100 double lleft, double lbottom, double lright, double ltop, 00101 int left=0, int top=0, int right=700, int bottom=700, 00102 bool logx=false, bool logy=false); 00103 00104 /** \brief Make a canvas and pad with more tick marks 00105 00106 This is the same as new_graph(), except it adds tick marks 00107 to the right and top axes, which are created with \c new and 00108 returned in \c a1 and \c a2 respectively(). 00109 00110 \future Modify this to just directly call new_graph() and add 00111 the new axes on top. 00112 */ 00113 int new_graph_ticks(TCanvas *&c1, TPad *&p1, TH1 *&th1, 00114 std::string CanvasName, 00115 std::string WindowName, 00116 std::string PadName, 00117 double lleft, double lbottom, double lright, 00118 double ltop, TGaxis *&a1, TGaxis *&a2, 00119 int left=0, int top=0, int right=700, 00120 int bottom=700, bool logx=false, bool logy=false); 00121 00122 /** \brief Graph two columns from a data table 00123 00124 This function plots the function defined by 00125 <tt>(scolx,scoly)</tt> given in table \c at with line style \c 00126 style and line color \c color. A \c TGraph object created with 00127 \c new is returned. The \c name of the graph object 00128 is automatically set to be the same as the \c scoly, but this 00129 can always be changed afterwards, i.e. 00130 \code 00131 g1=table_graph(at,scolx,scoly); 00132 g1->SetName("Curve name"); 00133 g1->Draw(); 00134 \endcode 00135 */ 00136 TGraph *table_graph(o2scl::table_units &at, std::string scolx, 00137 std::string scoly, int style=1, int color=1); 00138 00139 /** \brief Plot colums from a data table with error bars 00140 */ 00141 TGraphErrors *table_graph_errors(o2scl::table_units &at, std::string scolx, 00142 std::string scoly, std::string xerr, 00143 std::string yerr, int style=1, int color=1); 00144 00145 /** \brief Make a canvas with a two-up graph, side-by-side 00146 00147 This function creates a canvas and two pads for a side-by-side 00148 plot with two different x-axes and the same y-axis. The x-axis 00149 of the left-hand plot has limits <tt>(lowx1,highx1)</tt> and 00150 the the x-axis for the right-hand plot has limits 00151 <tt>(lowx2,highx2)</tt>. 00152 00153 */ 00154 int two_up_graph(TCanvas *&c1, TPad *&p1, TPad *&p2, TH1 *&th1, TH1 *&th2, 00155 std::string CanvasName, std::string WindowName, 00156 std::string Pad1Name, std::string Pad2Name, 00157 double lowx1, double highx1, double lowx2, double highx2, 00158 double lowy, double highy, 00159 int left=0, int top=0, int right=1000, int bottom=700, 00160 bool logx1=false, bool logx2=false, bool logy=false, 00161 double alpha=1.3, double margin=0.1); 00162 00163 /** \brief Make a canvas with two plots, one on top of the other 00164 00165 The variable \c p1 is on bottom and \c p2 is on top 00166 */ 00167 int two_up_graphy(TCanvas *&c1, TPad *&p1, TPad *&p2, 00168 TH1 *&th1, TH1 *&th2, 00169 std::string CanvasName, std::string WindowName, 00170 std::string Pad1Name, std::string Pad2Name, 00171 double lowx, double highx, 00172 double lowy1, double highy1, 00173 double lowy2, double highy2, 00174 int left=0, int top=0, int right=1000, int bottom=700, 00175 bool logx=false, bool logy1=false, bool logy2=false, 00176 double alpha=1.3, double margin=0.1); 00177 00178 /// \name Some useful colors 00179 //@{ 00180 const int kGray20=kGray; 00181 const int kGray40=kGray+1; 00182 const int kGray60=kGray+2; 00183 const int kGray80=kGray+3; 00184 //@} 00185 00186 /// \name Markers 00187 //@{ 00188 const int m_small_dot=1; 00189 const int m_plus=2; 00190 const int m_asterisk=3; 00191 const int m_circle=4; 00192 const int m_times=5; 00193 const int m_med_dot=6; 00194 const int m_large_dot=7; 00195 const int m_fill_circle=8; 00196 const int m_fill_square=21; 00197 const int m_fill_up_triangle=22; 00198 const int m_fill_dn_triangle=23; 00199 const int m_open_circle=24; 00200 const int m_open_square=25; 00201 const int m_open_up_triangle=26; 00202 const int m_open_diamond=27; 00203 const int m_open_plus=28; 00204 const int m_fill_star=29; 00205 const int m_open_star=30; 00206 const int m_asterisk2=31; 00207 const int m_open_dn_triangle=32; 00208 const int m_fill_diamond=33; 00209 const int m_fill_plus=34; 00210 //@} 00211 00212 } 00213 00214 #endif 00215
Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).