question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Behavior of AddFill in complex scenarios

See original GitHub issue

Hi @swharden & Team,

i have played a little with the function: Polygon AddFill(double[] xs1, double[] ys1, double[] xs2, double[] ys2, Color? color = null) It looks like the function is not intended for complex scenarios. That is, a variable number of values on the X-axis or Y-axis. The following errors occur if xs1 and xs2 is different:

System.IndexOutOfRangeException: Index was outside the bounds of the array. at ScottPlot.Plot.AddFill(Double[] xs1, Double[] ys1, Double[] xs2, Double[] ys2, Nullable`1 color) at ExchangePlotter.InteractivChart.AddData(ChartInput ci) in d:\Code\ExchangePlotter\InteractivChart.cs:line 78

If the number of xs1 and xs2 is equal but ys1 and ys2 have different amounts, this exception happens:

System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array’s lower bounds. at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable) at ScottPlot.Plot.AddFill(Double[] xs1, Double[] ys1, Double[] xs2, Double[] ys2, Nullable`1 color) at ExchangePlotter.InteractivChart.AddData(ChartInput ci) in d:\Code\ExchangePlotter\InteractivChart.cs:line 78

This is not urgent. It would be cool if the number of points for X/Y didn’t matter. As long as the areas for xs1, xs2 overlap, interpolation would certainly be possible to find “missing” points on one or the other line to span the polygon. Is probably very complex to implement? I’ll leave it here in case someone is bored 😉

Version: ScottPlot 4.1.8-beta

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AlgoExecutorcommented, Feb 21, 2021

Thank you @bclehmann for the quick feedback and explanation. Than i think we can close the ticket. I know how i can do it! 👍

0reactions
bclehmanncommented, Feb 21, 2021

For 1) It plots between curves by creating a closed polygon out of the two curves. In this situation that polygon intersects itself. The only alternative I can think of is to only create the polygon where the x-value overlap (i.e. ignore the second half of xs1 and ys1 in the example I gave). I don’t particularly like that alternative because in my mind that’s not the behavior I would expect in this situation.

For 2), AddFill returns a PlottablePolygon which has a Label field that you can edit and can show up in the legend.

For 3) I believe you can simply pass in a colour to AddFill with whatever degree of opacity you want (i.e. the alpha channel can be set to 0 for full transparency or 255 for full opacity or anywhere in between).

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is Complex Behavior? - Video & Lesson Transcript
Complex behaviors combine innate (instinctual) behaviors with learned behaviors as the individual interacts with their environment. Innate ...
Read more >
SQL Fill Factor & Excessive Fragmentation
There are many symptoms of excessive index fragmentation. Certain queries may deteriorate in performance because they perform excessive IOs ...
Read more >
Change Element Fill
Used to change a closed element (shape, ellipse, or complex shape, or B-spline curve) to the Active Fill Type. You can access this...
Read more >
based restoration - project implementation and monitoring ...
Good examples of maintenance specifications at the complex scale include “add additional willow to top of posts for all structures in complex”, ...
Read more >
Add fill to shapes · Issue #85 · xournalpp ...
Creating filled objects would be pleasant. This has been in the works for a while but I don't see a direct path to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found