Skip to content

ScottPlot 4 Image: GetAxisLimits() returns incorrect value #3515

@bukkideme

Description

@bukkideme

Issue:

1.Run the code sample, ScottPlot 4.1.72, .NET Framework 4.8 Winforms
2. pan away, zoom out, etc
3. mouse middle clixck
4. result: the image is not in the center

ScottPlot Version:
ScottPlot 4.1.72, .NET Framework 4.8 Winforms

Code Sample:

namespace BitmapTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            double pixelSizeuM = 3.2;
            Bitmap monaLisa = DataGen.SampleImage();

            var displayImage = formsPlot.Plot.AddImage(monaLisa, 0, 0, anchor: Alignment.MiddleCenter);

            displayImage.HeightInAxisUnits = monaLisa.Height * pixelSizeuM;
            displayImage.WidthInAxisUnits = monaLisa.Width * pixelSizeuM;

            double xRelative = displayImage.WidthInAxisUnits.Value / 2;
            double yRelative = displayImage.HeightInAxisUnits.Value / 2;
            //plot fix marker to show center
            var crosshair = formsPlot.Plot.AddMarker(0, 0, MarkerShape.cross, size: 30, color: Color.Red);
            crosshair.MarkerLineWidth = 2;

            formsPlot.Plot.SetAxisLimits(xMin: -xRelative, xMax: xRelative, yMin: -yRelative, yMax: yRelative);
            formsPlot.Plot.AxisScaleLock(true);


            formsPlot.Refresh();
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueThis issue has limited complexity and may be a good start for new contributorsHelp WantedScott won't do this soon, but PRs from the community are welcome!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions