Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13483 +/- ##
==========================================
- Coverage 89.95% 89.92% -0.04%
==========================================
Files 459 460 +1
Lines 32173 32372 +199
==========================================
+ Hits 28942 29111 +169
- Misses 3231 3261 +30
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Ref skjermbildet, hva betyr det øverste totallet? |
49c1688 to
bc27452
Compare
|
I would add |
bc27452 to
b23a469
Compare
b23a469 to
b94dc64
Compare
b94dc64 to
f158ee0
Compare
|
Added label to appear on cursor hover position! |
60a822f to
c5a3c79
Compare
| for bar_container_idx, bars in enumerate(data[0]): | ||
| for bar_idx, bar in enumerate(bars): | ||
| if bar.contains(event)[0]: | ||
| value = bar.get_height() | ||
|
|
||
| hover_box.xy = (event.xdata, event.ydata) # type: ignore | ||
| idx = bar_idx * len(data[0]) + bar_container_idx | ||
| hover_box.set_text(f"{data[1][idx]}\nValue: {value:.3g}") | ||
| hover_box.set_visible(True) | ||
| figure.canvas.draw_idle() | ||
| return |
There was a problem hiding this comment.
Regarding this tuple passed into this function, the use of data[0] and data[1] hides the content, making this a bit harder for the reader to understand what is going on.
Can we combine and create this up front instead? Thus avoiding much of the logic later on?
bar_label_pairs: list[tuple[Rectangle, str]] = []
for i, control in enumerate(self.selected_controls):
color = colors[i % len(colors)][0]
values = []
for batch_id in batch_ids:
batch_data = combined[combined["batch_id"] == batch_id]
match = batch_data[batch_data["control_name"] == control]
values.append(
match[response_key].to_numpy()[0] if not match.empty else 0.0
)
offsets = pos + (i - n_controls / 2) * bar_width + bar_width / 2
bars = axes.bar(
offsets,
values,
width=bar_width,
color=color,
alpha=0.7,
)
config.addLegendItem(control, bars[0])
for batch_id, bar in zip(batch_ids, bars):
bar_label_pairs.append((bar, f"batch {batch_id}\n{control}"))
There was a problem hiding this comment.
I agree it is clunky as it is now, im also thinking we might do something like this for the function signature of labels_on_hover
@staticmethod
def labels_on_hover(
axes: Axes,
plot_context: PlotContext,
figure: Figure,
**kwargs
) -> None:As we dont yet know exactly what data the different plot types require and that they will most likely differ.
a2ea499 to
36fa2c5
Compare
Screen.Recording.2026-05-06.at.15.19.48.mov |
This looks good to me, with a couple of nitpicky comment-questions:
|
36fa2c5 to
9ff29b8
Compare
That looks great! I forgot about the zoom -- that's sufficient, then, no need to mess around with hover hit zones then. 😄 (And I think RGBA would maybe just obfuscate things if we can otherwise go with "white", which is readable to everyone.) |
|
I support the color change 🥇 |

Issue
Resolves #13474
Add support for on-hover labels for bar plots.
PlotToolshave been updated with a new method that takes care of on-hover labeling and its currently only supported for bar plots, but the template is outlined for different type of plots.Math Func example
Egg example