Object-oriented Scientific Computing Library: Version 0.910
Functions
o2scl_graph Namespace Reference

Namespace for experimental functions for use with Root. More...


Detailed Description

This namespace contains several functions, defined in graph.cpp, which simplify plotting with Root. They require that the Root libraries have been installed and are not compiled in with the normal O2scl libraries. Some of the example plots created for the documentation are based on these functions.

Functions

void arrow (double x1, double y1, double x2, double y2, TLine *&line, TPolyLine *&poly, double size=0.1, double size2=0.8, double alpha1=0.35)
 Draw a pretty arrow from (x1,y1) to (x2,y2)
int new_graph (TCanvas *&c1, TPad *&p1, TH1 *&th1, std::string CanvasName, std::string WindowName, std::string PadName, double lleft, double lbottom, double lright, double ltop, int left=0, int top=0, int right=700, int bottom=700, bool logx=false, bool logy=false)
 Make a canvas and pad.
int new_graph_ticks (TCanvas *&c1, TPad *&p1, TH1 *&th1, std::string CanvasName, std::string WindowName, std::string PadName, double lleft, double lbottom, double lright, double ltop, TGaxis *&a1, TGaxis *&a2, int left=0, int top=0, int right=700, int bottom=700, bool logx=false, bool logy=false)
 Make a canvas and pad with more tick marks.
TGraph * table_graph (o2scl::table_units &at, std::string scolx, std::string scoly, int style=1, int color=1)
 Graph two columns from a data table.
TGraphErrors * table_graph_errors (o2scl::table_units &at, std::string scolx, std::string scoly, std::string xerr, std::string yerr, int style=1, int color=1)
 Plot colums from a data table with error bars.
int two_up_graph (TCanvas *&c1, TPad *&p1, TPad *&p2, TH1 *&th1, TH1 *&th2, std::string CanvasName, std::string WindowName, std::string Pad1Name, std::string Pad2Name, double lowx1, double highx1, double lowx2, double highx2, double lowy, double highy, int left=0, int top=0, int right=1000, int bottom=700, bool logx1=false, bool logx2=false, bool logy=false, double alpha=1.3, double margin=0.1)
 Make a canvas with a two-up graph, side-by-side.
int two_up_graphy (TCanvas *&c1, TPad *&p1, TPad *&p2, TH1 *&th1, TH1 *&th2, std::string CanvasName, std::string WindowName, std::string Pad1Name, std::string Pad2Name, double lowx, double highx, double lowy1, double highy1, double lowy2, double highy2, int left=0, int top=0, int right=1000, int bottom=700, bool logx=false, bool logy1=false, bool logy2=false, double alpha=1.3, double margin=0.1)
 Make a canvas with two plots, one on top of the other.

Variables

Some useful colors
const int kGray20 = kGray
const int kGray40 = kGray+1
const int kGray60 = kGray+2
const int kGray80 = kGray+3
Markers
const int m_small_dot = 1
const int m_plus = 2
const int m_asterisk = 3
const int m_circle = 4
const int m_times = 5
const int m_med_dot = 6
const int m_large_dot = 7
const int m_fill_circle = 8
const int m_fill_square = 21
const int m_fill_up_triangle = 22
const int m_fill_dn_triangle = 23
const int m_open_circle = 24
const int m_open_square = 25
const int m_open_up_triangle = 26
const int m_open_diamond = 27
const int m_open_plus = 28
const int m_fill_star = 29
const int m_open_star = 30
const int m_asterisk2 = 31
const int m_open_dn_triangle = 32
const int m_fill_diamond = 33
const int m_fill_plus = 34

Function Documentation

void o2scl_graph::arrow ( double  x1,
double  y1,
double  x2,
double  y2,
TLine *&  line,
TPolyLine *&  poly,
double  size = 0.1,
double  size2 = 0.8,
double  alpha1 = 0.35 
)

The parameter size determines the size of the head relative to the size of the arrow, size2 determines the position of the niche (1.0 is no niche), and alpha1 determines the angle of the head relative to the line (default is about 20 degrees).

int o2scl_graph::new_graph ( TCanvas *&  c1,
TPad *&  p1,
TH1 *&  th1,
std::string  CanvasName,
std::string  WindowName,
std::string  PadName,
double  lleft,
double  lbottom,
double  lright,
double  ltop,
int  left = 0,
int  top = 0,
int  right = 700,
int  bottom = 700,
bool  logx = false,
bool  logy = false 
)

The CanvasName is the default output filename for graphs and macros also. The PadName is the name that comes up when you right-click on the pad. When making .eps files, the Title field is set to "CanvasName.eps: Windowname". This Title field is the title that appears, e.g., in a ghostview window. The x-axis limits are given by lleft and lright and the y-axis limits are given in lbottom and ltop. The upper left corner of the canvas window is at (left,top) and the lower right corner is (right,bottom). The parameters logx and logy determine whether or not the x- or y-axes are logarithmic instead of linear (the default). The canvas and pad objects are created using new, and the histogram object th1 is created with TPad::DrawFrame().

int o2scl_graph::new_graph_ticks ( TCanvas *&  c1,
TPad *&  p1,
TH1 *&  th1,
std::string  CanvasName,
std::string  WindowName,
std::string  PadName,
double  lleft,
double  lbottom,
double  lright,
double  ltop,
TGaxis *&  a1,
TGaxis *&  a2,
int  left = 0,
int  top = 0,
int  right = 700,
int  bottom = 700,
bool  logx = false,
bool  logy = false 
)

This is the same as new_graph(), except it adds tick marks to the right and top axes, which are created with new and returned in a1 and a2 respectively().

Idea for Future:
Modify this to just directly call new_graph() and add the new axes on top.
TGraph* o2scl_graph::table_graph ( o2scl::table_units &  at,
std::string  scolx,
std::string  scoly,
int  style = 1,
int  color = 1 
)

This function plots the function defined by (scolx,scoly) given in table at with line style style and line color color. A TGraph object created with new is returned. The name of the graph object is automatically set to be the same as the scoly, but this can always be changed afterwards, i.e.

      g1=table_graph(at,scolx,scoly);
      g1->SetName("Curve name");
      g1->Draw();
int o2scl_graph::two_up_graph ( TCanvas *&  c1,
TPad *&  p1,
TPad *&  p2,
TH1 *&  th1,
TH1 *&  th2,
std::string  CanvasName,
std::string  WindowName,
std::string  Pad1Name,
std::string  Pad2Name,
double  lowx1,
double  highx1,
double  lowx2,
double  highx2,
double  lowy,
double  highy,
int  left = 0,
int  top = 0,
int  right = 1000,
int  bottom = 700,
bool  logx1 = false,
bool  logx2 = false,
bool  logy = false,
double  alpha = 1.3,
double  margin = 0.1 
)

This function creates a canvas and two pads for a side-by-side plot with two different x-axes and the same y-axis. The x-axis of the left-hand plot has limits (lowx1,highx1) and the the x-axis for the right-hand plot has limits (lowx2,highx2).

int o2scl_graph::two_up_graphy ( TCanvas *&  c1,
TPad *&  p1,
TPad *&  p2,
TH1 *&  th1,
TH1 *&  th2,
std::string  CanvasName,
std::string  WindowName,
std::string  Pad1Name,
std::string  Pad2Name,
double  lowx,
double  highx,
double  lowy1,
double  highy1,
double  lowy2,
double  highy2,
int  left = 0,
int  top = 0,
int  right = 1000,
int  bottom = 700,
bool  logx = false,
bool  logy1 = false,
bool  logy2 = false,
double  alpha = 1.3,
double  margin = 0.1 
)

The variable p1 is on bottom and p2 is on top

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.