Why isn't my code producing a graph with a log scale in C++?

  • C/C++
  • Thread starter lavster
  • Start date
  • Tags
    C++ Scale
In summary, the conversation is about a person trying to fix their code for creating a graph with a log scale using the ROOT package from CERN. They have tried multiple methods and are now asking for help on a forum dedicated to ROOT.
  • #1
lavster
217
0
can someone tell me what is wrong with my code. i get the graph that i want but not with the log scale... i have tried multiple methods. this is the last one i tried (its part of a canvas which is split into quadrants)

TH1F* h3 = (TH1F*) inputfile3 -> Get("pdg");
c->cd(3);
h3->GetXaxis()->SetTitle("pdg code (high)");
h3->Draw();

c->Modified();
c->Update();
c->SetLogy(1);
c->Modified();

and then onto other quadrant...

thanks :)
 
Technology news on Phys.org
  • #2
Which library or package are these from? They're not part of the standard C++ language.
 
  • #3
sorry i don't quite understand your question (my understanding of comp is very limited). ROOT? and I've called them the histograms from another .C macros thing

thanks
 
  • #4
I did a Google search for some of the function names. You're using the ROOT package from CERN. They have a whole website about ROOT:

http://root.cern.ch/drupal/

It includes a forum, where you might try asking your question if you can't find your answer in the documentation or a FAQ:

http://root.cern.ch/phpBB3/
 
Last edited:
  • #5
ill have a look - cheers!
 

FAQ: Why isn't my code producing a graph with a log scale in C++?

1. Why is my logarithmic scale not working in my C++ code?

The logarithmic scale may not be working because you have not specified the correct syntax for creating a log scale graph. In C++, you need to use the "log" function from the math library to calculate the logarithmic values for your data points.

2. How do I specify a logarithmic scale in my C++ code?

To specify a logarithmic scale in C++, you must use the "setScale" function from the graphing library. This function allows you to specify the type of scale (linear or logarithmic) as well as the base for the logarithmic scale.

3. Why is my graph with a log scale showing incorrect values?

If your graph with a log scale is showing incorrect values, it could be due to errors in your data or in the calculation of the logarithmic values. Make sure that you are using the correct formula for calculating the logarithm and that your data is accurate.

4. Can I change the base of my logarithmic scale in C++?

Yes, you can change the base of your logarithmic scale in C++ by using the "setBase" function from the graphing library. This function allows you to specify the desired base for your logarithmic scale.

5. How can I troubleshoot issues with my C++ code for producing a graph with a log scale?

If you are having issues with your C++ code for producing a graph with a log scale, start by checking for any syntax errors in your code. Then, make sure that you are using the correct functions and libraries for creating a log scale graph. If the issue persists, try debugging your code to identify any logical errors or consult online resources or forums for further assistance.

Back
Top