Skip to content

New plot type: ErrorBar#1588

Merged
swharden merged 16 commits intoScottPlot:masterfrom
bclehmann:feature/error-bar
Jan 23, 2022
Merged

New plot type: ErrorBar#1588
swharden merged 16 commits intoScottPlot:masterfrom
bclehmann:feature/error-bar

Conversation

@bclehmann
Copy link
Member

@bclehmann bclehmann commented Jan 22, 2022

New Contributors:
Please review CONTRIBUTING.md

Hacktoberfest Participants:
Check-out the Hacktoberfest 2021 page

Purpose:
#1466
image

@bclehmann bclehmann marked this pull request as draft January 22, 2022 02:07
@bclehmann bclehmann marked this pull request as ready for review January 22, 2022 02:58
@bclehmann
Copy link
Member Author

For what it's worth, it's been a while since I've made a PR that touched rendering (I think it was #1188...) and I have to say that things like Coordinate and Pixel seem like a nice common-sense addition. I remember a lot of tuple-wrangling before.

It might even be possible to claw back some performance by converting them to structs since they're small and potentially could be allocated every render.

@swharden
Copy link
Member

swharden commented Jan 22, 2022

things like Coordinate and Pixel seem like a nice common-sense addition

Thanks! I made them because I kept confusing myself passing (double x, double y) 😝

It might even be possible to claw back some performance by converting them to structs since they're small and potentially could be allocated every render

If I'm going to refactor ScottPlot 4, it'll probably be to favor readability and portability over performance. Switching to Maui.Graphics in ScottPlot 5 will be a pretty big shake-up, so it may not be worth optimizing ScottPlot 4 at this time.

BTW you might get a kick out of #1561 - It's barebones but the WinForms app is the most developed. I'm experimenting with architecture. After a few years getting to know the pain points of this library, I'm leaning toward minimizing state stored in the plot module itself. Types like AxisLimits, Pixel, and Coordinate are structs with a fluent interface. I don't intend to greatly change the public API (the plot methods will be essentially the same), but I'm starting to like things like this...

PlotView mouseDownView = plt.GetAxisLimits();
PlotView currentView = mouseDownView.WithPan(mouseDownPixel, mouseNowPixel);
Bitmap bmp = plt.Render(currentView);

None of this is set in stone (I'm still waiting for Maui.Graphics to mature - it's getting there though), but it's interesting to consider after working with this library and having a good understanding of its roughest edges.

@swharden swharden linked an issue Jan 23, 2022 that may be closed by this pull request
@swharden
Copy link
Member

Great work as always @bclehmann, thanks so much for this PR! I'll merge this now and release this weekend.

This could even be extended in the future by adding a MarkerShape and MarkerSize to allow people to make plots like this (although I'd probably use the same color for the error lines and the marker)

EDIT: I'll put this in now real quick, then merge

image

@swharden swharden enabled auto-merge January 23, 2022 03:18
@swharden swharden merged commit 25496e0 into ScottPlot:master Jan 23, 2022
@swharden swharden changed the title Creates errorbar plottable and cookbook New plot type: ErrorBar Jan 23, 2022
@bclehmann
Copy link
Member Author

bclehmann commented Jan 23, 2022

Sorry, I found this after you merged, but there's a bug in the error bar rendering code. They can be drawn outside the plotting frame.

image

I'm confused why this happens, because I don't think the other plottables check for points outside the frame, but they don't seem to suffer from this problem.

swharden added a commit that referenced this pull request Jan 23, 2022
@swharden
Copy link
Member

Sorry, I found this after you merged

No worries! It'll be a few hours before I publish the next package, so this fix will make it in

I'm confused why this happens, because I don't think the other plottables check for points outside the frame, but they don't seem to suffer from this problem

My trick is to avoid calling Graphics.FromImage(bmp) and instead I call an internal method which clips the data area according to the PlotDimensions - here's the fix 6bb43a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ErrorBar: New plot type for advanced error bar features

2 participants