Skip to content

Annotation: add support for center positioning #2302

@EFeru

Description

@EFeru

ScottPlot Version: 4.1.59

Operating System: W10

Application Type: WinForms

Question: Hi, is there a way to place annotation in the middle of the axes? So, top-middle, bottom-middle, left-middle, right-middle (see picture below in green). I show a Delta caluculation in my plot and it feels more natural to place it in the middle.

I already looked if there is a method to get the plot limits in pixels and caculate the middle myself, however couldn't find one. The closest I could get is to get the Axis limits in data coordinate, calculate middle and then convert it to pixel coordinate. However, I think I am over-doing it this way. Let me know what you think.

AxisLimits ax = formsPlot.Plot.GetAxisLimits();
double middleXPixel = formsPlot.Plot.GetPixelX(ax.XCenter);
formsPlot.Plot.AddAnnotation("Delta", middleXPixel, -10);  // Position to Lower-middle

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions