Graph with strings as x axis

To start, I know it’s not possible to have alphanumerical axis for graphs. I’ve based my code off the previous posts asking this but they aren’t that clear.
Here’s the abstract problem:
I have a vector of strings and a vector of doubles. How can I make a graph or something that looks like a graph? Should I just make a histogram and pretend it’s a graph? Should I overlay a histogram with the strings as bins onto a graph while deleting the graph’s x axis? Bonus points: red markers for the values, with not line connecting them.

_ROOT Version:_6.18/04
Platform: Windows
Compiler: Not Provided

Alternative question:
I can draw a graph:

and a histogram:

But not both in one canvas/one run of the macro. If I put any option in the histogram’s Draw(), the graph stays, and if I pass no options to the histogram’s Draw(), the histogram is drawn as in the second image. I’ve tried Draw(“SAME”)

GraphDoubleString.C (944 Bytes)

root [0] double x[3] = {1,2,3};  double y[3] = {1,5,2}; string colour[3] = { "Blue", "Red", "Green"}; auto gr = new TGraph(3,x,y);
root [1] gr->SetMarkerStyle(20)
root [2] .x GraphDoubleString.C(gr,colour)

I’ll try this, thank you. Is string* col just a blank pointer and so when you call col[i] its always blank or something like that?

It allows to pass the array of strings to the TExec function.

I’ve changed my arrays to double instead of Double_t. Because I’m bringing in stuff from vectors, I’m filling the arrays with a for loop. Still a blank canvas.

Is there a problem here? Assume the vectors are valid when passed in.

void plot(vector<double> conc, vector<string> date) {
    //x and y axis of graph
    double x[conc.size()];
    double y[conc.size()];
    string z[date.size()];
    for (int i = 0; i < conc.size();i++) {
        x[i] = i;
        y[i] =;
        z[i] =;
    auto graph = new TGraph(conc.size(), x, y);
    delete graph;

when you use the macro I sent you as I suggested in my first post, does it work for you ?

Yes, when I run that code it does work.

So it should be used that way . Can you post something reproducing what you are doing ?

What does that mean? Should I post files, or code or a description?

Some code I can run to test what you are doing. The macro I sent you works when used I instructed. You are surely using it in some other way. I need to see (and try) what you do.

Note the col global variable at the top of the macro, and the path you need to change in the macro’s list_files function. The main function is at the bottom and the relevant functions to this bug are near the bottom. I’ve thrown your macro in but it’s not working. I’m going to check the arrays real quick.

I added a local col to DrawLabels(), should probably be removed

I made a simpler version
plot.C (1004 Bytes)

root [0] .x plot.C

Almost perfect.

This might be inevitable, but the words are horizontal Can I make them vertical? Also, how can I save the canvas to pdf?

Got the text angle with t->SetTextAngle(90);

Is there a list of SetTextAlign and SetTextFont etc. options? If it’s in the documentation I must be missing it.

Text attributes are described here:

Ok I just used a for loop to test:
How can I access the canvas to make it bigger and save it as a pdf progamatically?