Skip to content

Add editable axis/title labels from plot - #13992

Merged
MagnusSletten merged 7 commits into
equinor:mainfrom
MagnusSletten:axis-name
Jul 21, 2026
Merged

Add editable axis/title labels from plot#13992
MagnusSletten merged 7 commits into
equinor:mainfrom
MagnusSletten:axis-name

Conversation

@MagnusSletten

@MagnusSletten MagnusSletten commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Issue
Resolves #13999
Resolves #14006

Approach
Enable picking on the x- and y-axis labels and plot title after each render, and handle Matplotlib pick events on the canvas. Selecting one opens a pre-filled input dialog. Accepted changes are stored in the active key’s PlotConfig history and applied immediately through the existing refresh mechanism. Clearing the input restores the default text.

Also removes the axis-label and title controls from the customization style tab.

image image
  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'just rapid-tests')

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Add backport label to latest release (format: 'backport release-branch-name')

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables in-plot editing of Matplotlib axis labels in the ERT GUI by making axis label artists pickable, emitting a Qt signal when a label is clicked, and opening an edit dialog in the plot window that persists changes via the active PlotConfig history.

Changes:

  • Add pick handling in PlotWidget to detect clicks on x/y axis label artists and emit an edit-request signal.
  • Add an edit flow in PlotWindow using QInputDialog, applying accepted label changes via PlotCustomizer.
  • Allow PlotConfig x/y label setters to accept None, and add unit tests covering the new signal + config update behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/ert/unit_tests/gui/tools/plot/test_plot_window.py Adds unit tests for axis-label click signal emission and PlotCustomizer.set_axis_label() updating PlotConfig.
src/ert/gui/plotting/widgets/plot_widget.py Connects Matplotlib pick_event, enables picking for axis labels, and emits axisLabelEditRequested.
src/ert/gui/plotting/utils/plot_config.py Updates x/y label setters to accept `str
src/ert/gui/plotting/plot_window.py Listens for axisLabelEditRequested and opens a pre-filled input dialog to edit/apply axis labels.
src/ert/gui/plotting/customization_dialog/customize_plot_dialog.py Adds PlotCustomizer.set_axis_label() to write label changes into PlotConfigHistory and refresh customization UI state.

Comment thread src/ert/gui/plotting/plot_window.py Outdated
@codecov-commenter

codecov-commenter commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.81319% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.57%. Comparing base (d74abf8) to head (a80187d).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
.../plotting/widgets/plot_controls/general_options.py 66.66% 9 Missing ⚠️
src/ert/gui/plotting/plot_window.py 94.87% 2 Missing ⚠️
...ting/customization_dialog/customize_plot_dialog.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13992      +/-   ##
==========================================
- Coverage   91.63%   91.57%   -0.07%     
==========================================
  Files         487      487              
  Lines       34380    34451      +71     
==========================================
+ Hits        31505    31549      +44     
- Misses       2875     2902      +27     
Flag Coverage Δ
cli-tests 35.71% <0.00%> (-0.09%) ⬇️
fuzz 43.51% <15.38%> (-0.07%) ⬇️
gui-tests 59.02% <39.56%> (-0.12%) ⬇️
performance-and-unit-tests 80.16% <86.81%> (-0.03%) ⬇️
test 45.81% <15.38%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...g/customization_dialog/style_customization_view.py 89.28% <ø> (+4.84%) ⬆️
src/ert/gui/plotting/widgets/plot_widget.py 88.72% <100.00%> (+2.11%) ⬆️
...ting/customization_dialog/customize_plot_dialog.py 81.54% <75.00%> (+0.67%) ⬆️
src/ert/gui/plotting/plot_window.py 80.04% <94.87%> (+1.72%) ⬆️
.../plotting/widgets/plot_controls/general_options.py 89.24% <66.66%> (-9.29%) ⬇️

... and 5 files with indirect coverage changes

@codspeed-hq

codspeed-hq Bot commented Jul 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing MagnusSletten:axis-name (a80187d) with main (d74abf8)

Open in CodSpeed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@MagnusSletten
MagnusSletten marked this pull request as ready for review July 13, 2026 12:12
@MagnusSletten MagnusSletten moved this to In Progress in SCOUT Jul 14, 2026
@ertomatic

Copy link
Copy Markdown
Collaborator

Screenshots differ from baselines. A baseline update PR has been prepared: equinor/ert-testdata#52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@MagnusSletten MagnusSletten changed the title Add editable axis labels from plot Add editable axis labels and limits from plot Jul 15, 2026
ertomatic pushed a commit to equinor/ert-testdata that referenced this pull request Jul 15, 2026
@eilskra eilskra removed this from SCOUT Jul 15, 2026
@eilskra eilskra added the improvement Something nice to have, that will make life easier for developers or users or both. label Jul 15, 2026
@MagnusSletten
MagnusSletten force-pushed the axis-name branch 2 times, most recently from 0295a76 to 8ca5c7b Compare July 17, 2026 06:59
@eilskra

eilskra commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Could we also add two buttons (Change x-label, Change y-label) to GeneralOptions that trigger same pop-up window?
Then we can remove it from CustomizationWidget 👍

@MagnusSletten

Copy link
Copy Markdown
Contributor Author

Could we also add two buttons (Change x-label, Change y-label) to GeneralOptions that trigger same pop-up window?
Then we can remove it from CustomizationWidget 👍

Sounds good! I'll do that. Sidenote: also noticed that the Limits tab looks awkward in customization widget, the text boxes are unnaturally tall.

@eilskra

eilskra commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@MagnusSletten

Sidenote: also noticed that the Limits tab looks awkward in customization widget, the text boxes are unnaturally tall.

Think the formatting is due to how its set initially. In general, the customization widget has a lot of issues, so I think we should have a move limits to GeneralOptions

I think I would split this PR in two, labels and limits, to prevent scope creep now that we can add more buttons. If we finish labels with this PR, then we can repeat the axis-click + additional buttons + customization widget field/tab removal, but for limits

Edit: Could prob add title too?

@MagnusSletten

Copy link
Copy Markdown
Contributor Author

I think I would split this PR in two, labels and limits, to prevent scope creep now that we can add more buttons. If we finish labels with this PR, then we can repeat the axis-click + additional buttons + customization widget field/tab removal, but for limits

I agree! I'll just move that limit related commit then.

ertomatic pushed a commit to equinor/ert-testdata that referenced this pull request Jul 21, 2026
Comment thread src/ert/gui/plotting/plot_window.py
Comment thread src/ert/gui/plotting/widgets/plot_controls/general_options.py
Comment on lines +109 to 114
self.update_plot_config(plot_config)

def update_plot_config(self, plot_config: PlotConfig) -> None:
history = self._get_plot_config_history()
history.apply_changes(plot_config)
self._emit_changed_signal()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a temp solution needed before removal of the CustomizationDialog or could this be skipped?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's like this to keep current per key plotting behaviour so that changes for titles remain when clicking between keys.

Comment on lines +78 to +92
self._change_x_label = QPushButton("Edit x-label")
self._change_x_label.setObjectName("change_x_label_button")
self._change_x_label.clicked.connect(
lambda: self.axisLabelEditRequested.emit("x")
)

self._change_y_label = QPushButton("Edit y-label")
self._change_y_label.setObjectName("change_y_label_button")
self._change_y_label.clicked.connect(
lambda: self.axisLabelEditRequested.emit("y")
)

self._change_title = QPushButton("Edit title")
self._change_title.setObjectName("change_title_button")
self._change_title.clicked.connect(self.titleEditRequested.emit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we reduce the duplication of code somehow? If fix leads to unnecessarily difficult to read code, then skip

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can absolutely be done 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in recent commit

Comment thread tests/ert/unit_tests/gui/plottery/test_plot_style.py Outdated
@eilskra

eilskra commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Could you add a couple of screenshots to display functionality and buttons?

ertomatic pushed a commit to equinor/ert-testdata that referenced this pull request Jul 21, 2026
@MagnusSletten
MagnusSletten force-pushed the axis-name branch 2 times, most recently from 23d3daa to c5cb2ea Compare July 21, 2026 12:18
ertomatic pushed a commit to equinor/ert-testdata that referenced this pull request Jul 21, 2026
ertomatic pushed a commit to equinor/ert-testdata that referenced this pull request Jul 21, 2026
@eqbech

eqbech commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

It is not obvious to me that it is possible to click on the axis labels and title to edit them. Is there an easy way to add some effect or something similar that shows that these are editable by clicking on them? E.g changing fontsize when hovered or background color or cursor type on hover etc.

@MagnusSletten

Copy link
Copy Markdown
Contributor Author

It is not obvious to me that it is possible to click on the axis labels and title to edit them. Is there an easy way to add some effect or something similar that shows that these are editable to clicking on them? E.g changing fontsize when hovered or background color or cursor type on hover etc.

Good point! Maybe actually this can be in a smaller separate PR? I will have an upcoming one for the limits as well.

ertomatic pushed a commit to equinor/ert-testdata that referenced this pull request Jul 21, 2026
@MagnusSletten
MagnusSletten requested a review from eilskra July 21, 2026 13:22
ertomatic pushed a commit to equinor/ert-testdata that referenced this pull request Jul 21, 2026
Comment on lines +69 to +92
self._change_x_label = create_edit_button(
"x-label",
lambda: self.axisLabelEditRequested.emit("x"),
)
self._change_y_label = create_edit_button(
"y-label",
lambda: self.axisLabelEditRequested.emit("y"),
)
self._change_title = create_edit_button(
"title",
self.titleEditRequested.emit,
)

edit_buttons = QWidget()
edit_buttons_layout = QHBoxLayout(edit_buttons)
edit_buttons_layout.setContentsMargins(0, 0, 0, 0)

for button in (
self._change_x_label,
self._change_y_label,
self._change_title,
):
edit_buttons_layout.addWidget(button)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for label, func in [ ("x-label", lambda: self.axisLabelEditRequested.emit("x")) ...]:
    edit_buttons_layout.addWidget(create_edit_button(label, func)

@MagnusSletten MagnusSletten Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, done! 👍

@eilskra eilskra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had one refactor comment, bar that LGTM

@MagnusSletten
MagnusSletten enabled auto-merge (rebase) July 21, 2026 14:05
ertomatic pushed a commit to equinor/ert-testdata that referenced this pull request Jul 21, 2026
@MagnusSletten
MagnusSletten merged commit 20cb24b into equinor:main Jul 21, 2026
30 checks passed
@eilskra eilskra removed the improvement Something nice to have, that will make life easier for developers or users or both. label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes:improvement Automatically categorise as improvement in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow users to edit the plot title by clicking it Clickable x-axis, y-axis and plot label (changing text)

6 participants