Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make multiple plots in a plan #15

Open
tacaswell opened this issue Jan 22, 2024 · 0 comments
Open

make multiple plots in a plan #15

tacaswell opened this issue Jan 22, 2024 · 0 comments

Comments

@tacaswell
Copy link
Contributor

two quick sketches for how to make use of multiple LivePlots in one scan:

from functools import partial

from ophyd.sim import hw as _hw

from bluesky import RunEngine
from bluesky.plans import scan
from bluesky.callbacks.mpl_plotting import LivePlot
import bluesky.callbacks
import bluesky.preprocessors as bpp


hw = _hw()

bluesky.callbacks.mpl_plotting.initialize_qt_teleporter()

RE = RunEngine({})

def same_axes():
   def get_ax():
       import matplotlib.pyplot as plt
       return plt.figure('my plot').gca()

   lt =  LivePlot('det', 'motor', marker='x', markersize=10, ax=get_ax)
   lt2 =  LivePlot('det1', 'motor', marker='o', markersize=10, ax=get_ax)   
   return (yield from bpp.subs_wrapper(scan([hw.det, hw.det1], hw.motor, -5, 5, 30), [lt, lt2]))


def same_figure():
   def get_ax(i):
       import matplotlib.pyplot as plt
       fig = plt.figure('my plot')
       if len(fig.axes) == 0:
           fig.subplots(1, 2)
       return fig.axes[i]

   lt =  LivePlot('det', 'motor', marker='x', markersize=10, ax=partial(get_ax, i=0))
   lt2 =  LivePlot('det1', 'motor', marker='o', markersize=10, ax=partial(get_ax, i=1))   
   return (yield from bpp.subs_wrapper(scan([hw.det, hw.det1], hw.motor, -5, 5, 30), [lt, lt2]))


RE(same_figure())

In your actual use the hard coded lt and lt2 can be replaced with a loop over the y-values of interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant