TGraph *g = new TGraph(10,x,y); g->SetFillStyle(3001); // Sets the fill style to diagonal lines g->Draw("AF"); // Draws the graph with the fill style
#includeIn this example, we first initialize a graphics window using the initwindow function from the graphics library. Then we create a TGraph object with 5 data points denoted by arrays x and y. We set the fill style of the graph to horizontal lines using the SetFillStyle function. Finally, we draw the graph with the fill style using the Draw function with the "AF" option. The conio.h library is included to wait for the user to press a key before closing the window. Package Library: ROOT, C++ Graphics Library#include #include int main() { initwindow(600, 400, "TGraph Fill Style Demo"); TGraph *g = new TGraph(5,x,y); g->SetFillStyle(10001); // Sets the fill style to horizontal lines g->Draw("AF"); // Draws the graph with the fill style getch(); closegraph(); return 0; }