.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\itom\plots\demo_AutoUpdatePlot.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_itom_plots_demo_AutoUpdatePlot.py: Auto-update plot =================== This demo shows two possibilities of how to create an auto updating plot, when the data does not come from a device allowing a live plot. .. GENERATED FROM PYTHON SOURCE LINES 6-12 .. code-block:: default from numpy import random import time from itom import dataObject from itom import plot1 .. GENERATED FROM PYTHON SOURCE LINES 14-18 Option 1: open plot with fixed interval, the plot shares its values from a given ``dataObject``, update the ``dataObject`` regularily and call the replot slot of the plot to force an update of the canvas (without that slot, the canvas is updated once the user makes a zoom, clicks somewhere...) .. GENERATED FROM PYTHON SOURCE LINES 18-28 .. code-block:: default d = dataObject.zeros([1, 3], "float64") [i, h] = plot1(d, properties={"yAxisInterval": (0, 1)}) t = time.time() for i in range(0, 50): d[0, :] = random.rand(3) h.call("replot") time.sleep(0.1) print("finished in %.2f s using replot" % (time.time() - t)) .. rst-class:: sphx-glr-script-out .. code-block:: none finished in 5.07 s using replot .. GENERATED FROM PYTHON SOURCE LINES 29-33 Option 2: similar to option 1, but the plot is continously given the same object again as source. Some caching mechanism provides a quick replot of the data. This option makes an automatic bounds-check of the new source and can therefore automatically reset automatic axes intervals .. GENERATED FROM PYTHON SOURCE LINES 33-41 .. code-block:: default [i, h] = plot1(d) t = time.time() for i in range(0, 50): d[0, :] = random.rand(3) h["source"] = d time.sleep(0.1) print("finished in %.2f s using autoupdate" % (time.time() - t)) .. rst-class:: sphx-glr-script-out .. code-block:: none finished in 5.12 s using autoupdate .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 10.432 seconds) .. _sphx_glr_download_11_demos_itom_plots_demo_AutoUpdatePlot.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_AutoUpdatePlot.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_AutoUpdatePlot.ipynb `