ScottPlot
ScottPlot copied to clipboard
SP5: Create Plot.Add.Annotation() for placing text on the figure (not bound to coordinates)
Mimic the design from ScottPlot 4 https://scottplot.net/cookbook/4.1/category/plottable-annotation/
The Benchmark plot type is close to having the functionality needed, just that the label can't be set
For added context, this is what I want it for https://scottplotstatsstorage.z20.web.core.windows.net/
I wouldn't mind taking a stab at this.
Here's my understanding of the implementation, please correct me:
- Annotation will be an implementation of
IPlottable - Text, its properties, and element rendering will be handled as a
Label. - Annotation should have an
Alignmentproperty that would control where the annotation is placed relative to axes. - Each
Alignmentenum value has to have an associated margin/offset value - Default formatting should resemble the SP4 annotation.
- What would be the best way to implement a margin? We could either go for
MarginXandMarginYproperties like in SP4 or opt for thePixelSizebased implementation?
Here's what I have so far, with margins at 0, and padding of 0 on the Labels:
I'd appreciate some guidance re. default offset values and margins on each axis.
@dlampa, thanks for your interest on this one! All your bullets seem reasonable, and I'm pretty flexible as to what the API should be. Whatever "feels right" is a great start, and we can refine as needed!
If you open a pull request with what you have, I'd be happy to look over the code and give a little more feedback! Adding this plot type is on my shortlist of upcoming goals, so the fact that you made this progress already is fantastic and I'm looking forward to learning more! 🚀
What would be the best way to implement a margin?
It sounds like you already have something like:
public Alignment Alignment; // determines where the annotation is placed
So maybe something like:
public float PaddingX = 5; // pixels from the horizontal edge
public float PaddingY = 5; // pixels from the vertical edge
Or:
public PixelPadding Padding = new (5, 5, 5, 5);
Either way, if you open up a pull request with what you've got so far, I'm happy to take a look (probably tonight) and can try out some different strategies and see what feels most consistent with the other ScottPlot 5 plot types.
Thanks again for working on this!
It's a pleasure to be able to contribute to this awesome project! I'll make a couple of updates based on your input - what I have in the meantime is in the PR.
resolved by #3510