ROOT Version: 6.22
Compiler: Root compiler
I want to plot the cylinder of equation x^2+y^2 = 25 and some data points(for example: 500 sample points with values of x,y,z) in a same 3D graph using TMultiGraph. But it giving the error like:
/home/subhrod/root/macros/cylinder.C:6:6: error: no matching member function for call to ‘Add’
/home/subhrod/root/include/TMultiGraph.h:53:22: note: candidate function not viable: no known conversion from ‘TF3 *’ to ‘TGraph *’ for 1st argument
virtual void Add(TGraph *graph, Option_t *chopt="");
How do I resolve this problem?
In order to draw both the cylinder and the data points, you can call
Draw() on the function object and on a
TGraph object. The second call should use the option
Draw("same"), in order to reuse the canvas.
That command will overlap both of the graph in one canvas. But I want to plot the curves in same graph so that I can visualise it on 3D, which is not possible by “same” method
TMultiGraph does not accept TF3, as the error says; it only accepts Graphs (or other TMultiGraphs), see its constructors in the documentation. Maybe you can create the graphs as TGraph2D and use “same”, as there is no TMultiGraph2D.
I have solved the problem by generating datapoints and use TGraph.