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

[New Feature] Single axis plot for two channels with same units in time series gui #124

Open
takuya-ulm opened this issue Mar 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@takuya-ulm
Copy link
Contributor

Feature Description

Currently, when the active channels are two with the same unit, the left axis is used for the first channel and the right one is used for the second channel automatically.

20240301_time_series

This is caused by the assignment of the axes in update_channel_settings below:

def update_channel_settings(self, enabled, averaged):
# Update combobox
self._mw.current_value_combobox.blockSignals(True)
try:
self._mw.current_value_combobox.clear()
self._mw.current_value_combobox.addItem('None')
self._mw.current_value_combobox.addItems(
[f'average {ch}' for ch in averaged if ch in enabled]
)
self._mw.current_value_combobox.addItems(enabled)
index = self._mw.current_value_combobox.findText(self._current_value_channel)
if index < 0:
self._mw.current_value_combobox.setCurrentIndex(0)
else:
self._mw.current_value_combobox.setCurrentIndex(index)
finally:
self._mw.current_value_combobox.blockSignals(False)
self._current_value_channel = self._mw.current_value_combobox.currentText()
# Update plot widget axes
self._streamer_constraints = self._time_series_logic_con().streamer_constraints
channel_units = self._streamer_constraints.channel_units
different_units = list({unit for ch, unit in channel_units.items() if ch in enabled})
self._channels_per_axis = list()
if len(different_units) == 2:
self._mw.trace_plot_widget.showAxis('right')
self._channels_per_axis = [
tuple(ch for ch in enabled if channel_units[ch] == different_units[0]),
tuple(ch for ch in enabled if channel_units[ch] == different_units[1])
]
if len(enabled) == 2:
self._mw.trace_plot_widget.setLabel('left',
self._channels_per_axis[0][0],
units=different_units[0])
self._mw.trace_plot_widget.setLabel('right',
self._channels_per_axis[1][0],
units=different_units[1])
else:
self._mw.trace_plot_widget.setLabel('left', 'Signal', units=different_units[0])
self._mw.trace_plot_widget.setLabel('right', 'Signal', units=different_units[1])
elif len(different_units) > 2:
self._mw.trace_plot_widget.hideAxis('right')
self._channels_per_axis = [tuple(enabled), tuple()]
self._mw.trace_plot_widget.setLabel('left', 'Signal', units='')
elif len(enabled) == 2:
self._mw.trace_plot_widget.hideAxis('right')
self._channels_per_axis = [(enabled[0],), (enabled[1],)]
self._mw.trace_plot_widget.setLabel('left',
enabled[0],
units=channel_units[enabled[0]])
self._mw.trace_plot_widget.setLabel('right',
enabled[1],
units=channel_units[enabled[1]])
elif len(enabled) > 2:
self._mw.trace_plot_widget.hideAxis('right')
self._channels_per_axis = [tuple(enabled), tuple()]
self._mw.trace_plot_widget.setLabel('left', 'Signal', units=different_units[0])
else:
self._mw.trace_plot_widget.hideAxis('right')
self._channels_per_axis = [tuple(enabled), tuple()]
self._mw.trace_plot_widget.setLabel('left', enabled[0], units=different_units[0])
for ch in channel_units:
show_channel = (ch in enabled) and self._visible_traces[ch][0]
show_average = show_channel and (ch in averaged) and self._visible_traces[ch][1]
self._toggle_channel_data_plot(ch, show_channel, show_average)

I would like to see them with the same single axis to compare the two values.

Related Problem

No response

Considered Alternatives

The channel states in the ChannelSettingsDialog can be used to assign the axes. For example, introduce 'Axis?' containing 'left' or 'right' or 'not shown' and assin the axis accordingly.

If two channels with different units are assigned to each axis, you can see them in each axis.
If several channels with the same units are assigned to one axis, you can compare them in the same axis.
If you want to focus one of them, you can assign it one axis and set the rest 'not shown' in the axis. Then, you can read that value.
If you are checking the stability of a value and not caring about the absolute value, you can also set it 'not shown'.

Additional Context

So far, all the data is plotted in one plot, this may be extended to several plots in a similar way.
By adding another parameter 'plot number' in the ChannelSettingsDialog, you can assign them to different plots.

Contact Details

[email protected]

@takuya-ulm takuya-ulm added the enhancement New feature or request label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant