ScottPlot / ScottPlot/ScottPlot

Effects of LastRender on GetNearest When Using Multiple Y-Axes

Open
#4,940 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.8k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

I'm plotting multiple Scatter plots on one FormsPlot, such that every Scatter is plotted on a different Y-axis (both left and right). I'm also using Scatter's GetNearest method to find the plotted point closest to the cursor's location on the FormsPlot.

I found that when first plotting a Scatter with a small Y-value range (40 and lower) on the default-left Y-axis, GetNearest won't return a real datapoint - even when the cursor hovers right above one of the Scatters plotted.
I figured that the reason is that LastRender is relative to the default axes, i.e. it gets the layout and size information from the main, default axes. Thus, when GetNearest uses LastRender to find a datapoint, it can only use the size of the default Y-axis - and if it's too small compared to other Y-axes with Scatters plotted on them, then it'll mess with GetNearest ability to find a proper point on the Scatters plotted on the large-Y-value-range Y-axes.

Is there a way to feed GetNearest a render object that takes in different axes than the default axes? Or is there another way to go around this problem, so I could use GetNearest properly even when the default Y-axis has a small value-range?
I would also love a deeper explanation on why and how does LastRender effects GetNearest - what information does LastRender holds, and how GetNearest uses it to find the closest point on a Scatter?

A huge thanks in advance for any help or response!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the multiple-Scatter, multiple-Y-axis scenario described in the issue, then inspect the GetNearest and LastRender entry points. Determine how axis-specific layout information is used and verify the behavior with a focused reproduction; done means nearest-point lookup works correctly across the plotted axes or the limitation and workaround are clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.