I am using Dash for a GUI for my physics experiment. The experiment involves scanning a light beam over an area and measuring intensity of the returned light. The area to scan and the step size per pixel is defined by the experimenter. That results in a predefined image of U*V pixels. After the user has set all the necessary settings, the start measuring button can be pressed. This will initialize a Heatmap graph in the layout, together with a dcc.Interval component to handle the automatic updating throughout the measurement. The name of the measurement and its associated data file is saved in a hidden Div component for the graph’s update callback to process.
The measurement process itself is started in a separate thread, to isolate it from the GUI itself and I don’t want to use a callback for that. The measured data is saved in the file and consists of a U*V dataframe starting with zero’s in the beginning of the measurement. After each pixel, the corresponding cell in the dataframe is updated and the dataframe is saved to the CSV. Now back to the update graph callback. This function reads the measured dataframe and returns a go.Figure(go.Heatmap …) to the dcc.Graph component every time that it is executed.
Above process of updating the graph seems to be a bit slow. It involves replacing the whole figure instead of updating just the data that the graph contains. Is it possible to just update the existing data by means of replacement i.e. not returning a complete go.Figure component? A way I know of how to do this is by adding traces. However, I would like the graph to start in a UV sized map and not extend after a new trace line has been added. Is it possible to pre-set the size UV and add traces until the measurement is done?