slaclab / pydm

Python Display Manager
http://slaclab.github.io/pydm/
Other
112 stars 77 forks source link

FIX: Plot Axis Name Change #1087

Closed zdomke closed 2 months ago

zdomke commented 3 months ago

This fixes a bug in the BasePlotAxisItem class where the name property will be set internally, but the axis' associated MultiAxisPlot will contain a dictionary with the wrong key-value pairing for the axis object.

AxisItem name bug example scenario:

  1. Create a BasePlotAxisItem with name "A" my_axis = BasePlotAxisItem(name="A")
  2. Change the name of the previous BasePlotAxisItem to "B" my_axis.name = "B"
  3. Create a BasePlotCurveItem and attach it to the BasePlotAxisItem using its new name my_curve = BasePlotCurveItem(yAxisName = "B")

This scenario produces a KeyError as the MultiAxisPlot.axes dictionary still uses "A" as the key to reference my_axis, but it should use "B".

Solution: Include a method in MultiAxisPlot for changing the name/key of an axis. Then, update the MultiAxisPlot.axes key in the BasePlotAxisItem.name property setter.

Another small change made in this PR is to fix the BasePlotAxisItem.label setter. Now it will call self.setLabel(self._label) to update its label on any associated plots.