RooFit plotting in JupyRoot 6.24

I was going through the tutorials for RooFit on PyROOT, and most of them contain the syntax that looks like the one below(line 68 of fitting composite pdf tutorial is an example of such):

df.plotOn(frame, LineColor="kRed")

I found the above syntax in (ROOT: Arguments for plotOn functions).

But when I run the syntax, I get the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-8-f62f79d4f25f> in <module>
----> 1 data.plotOn(frame, LineColor="kRed")

TypeError: none of the 2 overloaded methods succeeded. Full details:
  RooPlot* RooAbsData::plotOn(RooPlot* frame, const RooLinkedList& cmdList) =>
    TypeError: RooAbsData::plotOn got an unexpected keyword argument 'LineColor'
  RooPlot* RooAbsData::plotOn(RooPlot* frame, const RooCmdArg& arg1 = RooCmdArg::none(), const RooCmdArg& arg2 = RooCmdArg::none(), const RooCmdArg& arg3 = RooCmdArg::none(), const RooCmdArg& arg4 = RooCmdArg::none(), const RooCmdArg& arg5 = RooCmdArg::none(), const RooCmdArg& arg6 = RooCmdArg::none(), const RooCmdArg& arg7 = RooCmdArg::none(), const RooCmdArg& arg8 = RooCmdArg::none()) =>
    TypeError: RooAbsData::plotOn got an unexpected keyword argument 'LineColor'

most importantly,

TypeError: RooAbsData::plotOn got an unexpected keyword argument 'LineColor'

I tried doing the following things:

from ROOT import * \\ same error as above

from ROOT.RooFit import * \\ same error as above

data.plotOn(frame, RooFit.LineColor="kRed") \\ SyntaxError

data.plotOn(frame, RooFit.LineColor("kRed")) \\ TypeError

none of the above worked. But the one below works like a charm:

data.plotOn(frame, RooFit.LineColor(ROOT.kRed)) \\ Works!!

I just wanted to share my snippets.
Also, wanted to ask the experts whether this is just a version problem, a Jupyter notebook problem, or anything else.

Thanks, and welcome!


ROOT Version: JupyROOT 6.24/00
Platform: CentOS Linux release 7.9.2009 (Core)
Compiler: Python 3.8.8


Hi @masterfelu,

Welcome back to the ROOT forum and many thanks for sharing your snippets!

I am inviting the relevant people to this topic so that they are aware of the issue @jonas, @etejedor. Again, thanks for reporting and sharing.

Cheers,
J.

Hi @masterfelu!

Which ROOT version are you using? The new Pythonic syntax is only available as of ROOT 6.26, as you can read in the release notes:
https://root.cern.ch/doc/v626/release-notes.html#new-pythonizations

If you want to look at the tutorials with the less pythonic ROOT 6.24 syntax, you have to select the tutorials for 6.24:
https://root.cern/doc/v624/group__tutorial__roofit.html

Cheers,
Jonas

1 Like

Thanks a lot, @jonas! That helps a lot!
I am using ROOT v6.24.
I thought that the date on this tutorial file from the latest release, Feb 2018, was way before v6.24 was released so it might have worked on v6.24. I guess I should have double-checked that.

Ah, I see where the confusion was coming from then! Right, the date written in the tutorial is when it was created, not when it was last edited.

Thanks for your understanding!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.