fermi-lat / Likelihood

BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Plots from end of gtlike not showing correctly #95

Open joeastro opened 4 years ago

joeastro commented 4 years ago

I was running the Likelihood with Python tutorial with version 1.9.13 (python3 testing). The plots shown in the attached screenshot should feature the calculated individual & summed emission in addition to the measured bin values (left plot) and horizontal dotted line at 0.0 (right plot.)

Screen Shot 2020-08-24 at 5 54 17 PM
dagorym commented 4 years ago

I just tried this with a clean install of the 1.9.13 build on a CentOS 7 docker container and it displayed the missing fit lines just fine. I'll try it on a Mac but I'm not sure I can get the remote X display to work across the VPN.

donhorner commented 4 years ago

I see the same thing as Joe on my mac. I would note that the plot later in the tutorial that use matplotlib directly works just fine.

The plots do display correctly if I run the tutorial using the Jupyter notebook Emily created which sets the plots to use the "inline" backend.

donhorner commented 4 years ago

After testing, this seems to also occur on macs with the current release version of the tools (1.2.23). I was able to get the lines to appear by resizing the window. It also seems to help to create a plot with matplotlib first before running the likelihood plotting command. There also seem to be issues with windows freezing. We'll need to figure this out at some point but won't hold up the next release for it. I'll keep the issue open, though.

dagorym commented 3 years ago

The displaying of the plots is corrected in version 2.0.14.

However, the plots are still not interactive. This is due to some change in the engine in Python 3 as they just worked in Python2. However, there are a few work arounds.

First, If you just want to get the windows to go away, you can click on the (grayed out) close button (red circle) in the plot and then hit enter in the command prompt. It registered the click in the window but doesn't act on it until the window has the chance to process events (which it apparently does briefly every time you hit enter on the command prompt).

Second, If you want to be able to temporarily interact with the window (resize, zoom, save the plot, etc) you can execute the following commands in the command line:

matplotlib.pyplot.pause( nn )

where nn is the number of seconds you want the window to remain active. The command prompt will become disabled until the time expires but the window will be fully interactive during that time.

Third, If you want the windows to remain active (and the command prompt inactive) until you close the windows, you can enter the following command on the command prompt:

matplotlib.pyplot.show(block=True)

This will keep the windows active but the only way to get the command prompt active is to close all the windows.

It should be possible to add the functionality to the tools to make the windows and command prompt active at the same time that involves writing an event loop handler into the tools which might be more work than we want to take on. The plots work in the Jupyter notebooks because the notebooks already have that event loop built into them.

donhorner commented 3 years ago

I don't think we've gotten questions about how to interact with the plots, so it probably not worth modifying the code (or at least not a priority). I think we can just refer people to your workarounds above if they have questions.