Use the code above. Type “root example.C+” into your command line. The graph is drawn. Close the graph. Then type gr->Draw(). That gives the following error:
Error: Symbol gr is not defined in current scope (tmpfile):1:
Error: Failed to evaluate gr->Draw()
*** Interpreter error recovered ***
I don’t understand why you can’t draw the graph at the command line when you draw it in the example.
By the way … to draw a graph you need the option A if you want to see the axis and define the users coordinates. You also need a drawing option like L P C … see the help: root.cern.ch/root/html/TGraphPainter.html
imaccouet:roottest couet$ root example.C+
*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 5.33/03 6 March 2012 *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************
ROOT 5.33/03 (trunk@43282, Mar 08 2012, 11:05:41 on macosx64)
CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Processing example.C+...
Info in <TUnixSystem::ACLiC>: creating shared library /Users/couet/roottest/./example_C.so
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [1] gr->Draw();
root [2]