c.Draw() appears empty or broken in pyroot

Hello!
I am completely new to the ROOT and I appreciate for your reply!

I am trying to plot some histogram and figure in jupyter notebook, but the c.Draw() does not work, showing a broken image icon and if I add %jsroot on, the image appears as empty. Is that because I am in a Windows environment? but I used Ubuntu LTS, it should not have problems. Somebody suggested to use Xming, but even if I launched Xming and unblock it from the firewall, this problem still remains.

Here is my code, just to create some random numbers to plot:

import ROOT
%jsroot on
h = ROOT.TH1F("myHisto","My Histo;X axis;Y axis",64, -4, 4)
rndmGenerator = ROOT.TRandom3()
for i in xrange(1000):
    rndm = rndmGenerator.Gaus()
    h.Fill(rndm)

c = ROOT.TCanvas()
h.Draw()
c.Draw()

ROOT Version: 6.22/00
Platform: Windows ubuntu 20.04 LTS, jupyter notebook

It appears like this, the image is completely blank:


Hello,

It could be related to Windows, in Linux your code works just fine.

@bellenot could you comment on this?

The only issue I can think of would be the missing (or misconfigured) X11 server (XMing or VcXsrc), since the code runs in ubuntu 20.04. Can you try to open a TBrowser (or a TCanvas) in a root session, to make sure you have graphics?

Thank you very much. I actually indeed didn’t know how to connect the X11 server previously. I checked the root session and it cannot plot.

I refer to this page: https://medium.com/@dhanar.santika/installing-wsl-with-gui-using-vcxsrv-6f307e96fac0 , I first download Vcxsrv (They said Xming is slower and old) and installed it in the windows, and then installed XFCE4 in the ubuntu and finally get the desktop GUI. Then I found there is no longer 0 client connected to the X server. I restarted the jupyter notebook it works well. Thanks again.

1 Like

Hello again,
I meet some problem with %jsroot on.
Why sometimes with %jsroot on the canvas appears nothing and if we want to run another drawing later, without %jsroot on the canvas is empty as well? But if we only run without %jsroot on at the very first time, it works perfectly.

It does not happen all the time, for example, the case illustrated above is with %jsroot on and it still draws.

Sorry, I cannot try right now. Maybe @etejedor can give it a try?

I can’t reproduce on Linux, it does not matter in which order I activate JSROOT. The only difference with on and off should be that the display is a static image or JS.

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