BCDA-APS / apstools

various tools for use with Bluesky at the APS
https://bcda-aps.github.io/apstools/latest/
Other
16 stars 9 forks source link

single plot window, persistent, most recent plot(s) #784

Open prjemian opened 1 year ago

prjemian commented 1 year ago

@strempfer asks (by email):

I am wondering if it would be possible in Bluesky to have a single plot window, that has different graphs, depending on how many detectors are used. It could have a title like ‘Bluesky plot window’ and would be always used no matter which motor is scanned. It also should display only the current scan. This would be similar to spec but with the possibility to have several graphs. The plot window should also always move to the top when a scan is started. Like it is now, after 10 min of scanning different motors you have either a lot of windows open or many different scans in one window and you always have to close all the old scan windows manually. If one needs to compare scans, there are other plotting tools available like polartools.diffraction.dbplot or similar. dbplot for example uses the title ‘Plot data’ for the plot window and plots always in this same window.

Would it be possible to have something like this through apstools that replaces the generic data plotting of Bluesky?

prjemian commented 1 year ago

This might be implemented better using a custom visualization application. A popular pattern now is to subscribe a kafka server to the RunEngine document stream. The run documents would be stored in a Kafka topic. A custom application would get the data from Kafka to visualize it. Separately, the databroker would get the same data and store it in MongoDB.

prjemian commented 2 months ago

New windows are created by lines that call plt.subplots(), such as in bluesky.callbacks.mpl_plotting:

                fig, ax = plt.subplots()

There are four such identical lines in this module. Perhaps they can be replace by a function that considers a user option to make a new Figure object (as the code does now) and re-use the existing Figure object as indicated by a new option. Each of these lines is embedded in a method with many lines. A local replacement (by subclassing from the ophyd code) would need to duplicate each of the methods, replacing the call to plt.subplots() with a new method.