@couet any idea of what could be going on with the graphics here?
Actually there is internal check you can do to check which backend you are using . On all Unix like machines it is X11 … Except on Mac where it is Cocoa unless you explicitly install ROOT yourself using X11.
There is an internal check? Is it something accessible from
gSystem? In all the other issues we have discussed it always appears that I am using the Cocoa back-end on this machine, I’ve never explicitly gone after X11 and don’t have XQuartz running.
So the assumption is that the frozen canvas has something to do with a conflict between the Cocoa back-end and matplotlib?
Oops … mistyped … there is NO …
I assumed as much. It would be a nice addition.
An idea about the frozen canvas?
That would be useful on Mac only … and most of time it will now return “Cocoa”
To me il looks like more a python issue. Do you see the same problem with C++ ?
Sure, but I could definitively say which back-end I was using.
matplotlib is a python package. Not sure how I could reproduce the issue in C++.
yes that way I hate using the python interface: it breaks the ROOT event loop … any way I found a script which does not froze the interface for me … don’t ask me why … sorry I am not an expert the ROOT python interface.
#!/usr/bin/env python import ROOT def main(): from array import array ROOT.gStyle.SetTimeOffset(0); x = [1461168044L, 1461353937L, 1461583342L, 1461583828L, 1461590925L, 1461592425L, 1461595103L, 1461681830L, 1462790854L, 1463833176L] Hist = ROOT.TH1D("hist", "hist",len(x)-1, array("d",x)) Hist.Draw("a") Hist.GetXaxis().SetTimeDisplay(1); Hist.GetXaxis().SetTimeFormat("%d-%m-%Y"); Hist.SetFillColor(5) Hist.SetMarkerStyle(1) y = [50,60,100,75,80,65,90,70,80,67] for i in range(0,10): Hist.SetBinContent(i,y[i]) Hist.Draw() raw_input() if __name__ == "__main__": main()
The python interface does not “break the ROOT event loop” … there is no such thing. No matter what the interface, “something” must call the event loop. In root.exe, this is part of the same loop that waits for CLI input, but in Python, ROOT did not write the CLI input loop, so it has to be something else. Anyway, in plain English: “freezing” just means that the event loop isn’t called.
Mac is different in that it enforces the use of the inputhook rather than a GUI thread to feed events (Cocoa limitation). Most likely mathplotlib uses the Python inputhook as well and doesn’t play nice (PyROOT does, by calling the old hook).
Possibly, reinstalling the ROOT input hook after loading mathplotlib could work:
The equivalent of:
is used throughout ROOT as an internal check.
This didn’t appear to have any effect.
I also, found this post after your suggestion about inputhooks. It did not resolve the issue either.
I found a “solution” on the forum, but it breaks the matplotlib plotting.
import matplotlib #This line fixes the interactivity issue, but now matplotlib doesn't work (see below). matplotlib.use('Agg') import matplotlib.pyplot as plt import ROOT gLine = ROOT.TGraph() gLine.SetPoint(0,0,1) gLine.SetPoint(1,2,3) gLine.Draw("ALP") ROOT.gPad.Update() #This plot never appears! plt.plot((0,2), (1,3)) plt.show() raw_input("Press Enter to exit...")
Well, you can’t use the GUI thread on Mac w/ Cocoa. Only other thing to try (although I see no reason why it should make a difference), is to trigger the ROOT “finalization” early:
import ROOT ROOT.kRed # force finalization import matplotlib.pyplot as plt
Sorry, I’m not going to install ROOT on my Mac to try things out (I don’t support PyROOT anymore).
This didn’t work either.
I appreciate you providing some suggestions even though you aren’t supporting it.
we could identify the cause of the issue. The problem arises when the _macosx library is loaded, namely:
from matplotlib.backends import _macosx
we are investigating.
Any progress on this? (Just bumping the thread to keep it from closing.)
thanks for the ping. Nothing conclusive yet.
Is this a JIRA ticket for this so I can let this thread lock?
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
Thanks, let’s follow the issue here: