Skip to content

Axes.SquareUnits() causes plots to zoom out when repeatedly resized #4422

@King-Taz

Description

@King-Taz

Issue: Plot does not resize as expected when window size changes using SquareUnits feature in Maui.

ScottPlot Version: 5.0.42

Code Sample:

In XAML on MainPage

    <Grid ColumnDefinitions="*" RowDefinitions="*" Padding="30,20,30,20">
        <ScottPlot:MauiPlot x:Name="MauiPlot1" Scale="1"/>
    </Grid>

In the code behind, call this method after app initialization

using Colors = ScottPlot.Colors;

        private void SimpleDrawPhasorPlot()
        {
            //Create arrow base coordinates used for all vectors
            Coordinates arrowBase = new(0, 0);

            // create arrow 1
            Coordinates arrow1Tip = new(5, 0);
            CoordinateLine arrow1Line = new(arrowBase, arrow1Tip);

            // add a simple arrow
            var arrow1 = MauiPlot1.Plot.Add.Arrow(arrow1Line);
            arrow1.ArrowFillColor = Colors.Red;
            arrow1.ArrowLineWidth = 0;
            arrow1.ArrowWidth = 5;
            arrow1.ArrowheadLength = 20;
            arrow1.ArrowheadAxisLength = 20;
            arrow1.ArrowheadWidth = 20;
            var dl1 = MauiPlot1.Plot.Add.Text("T(1)", arrow1Tip);
            dl1.LabelFontSize = 36;
            dl1.LabelFontColor = Colors.Black;

            // force pixels to have a 1:1 scale ratio
            MauiPlot1.Plot.Axes.SquareUnits();

            //Autoscale
            MauiPlot1.Plot.Axes.AutoScale();
        }

When app starts, resizing the window several times shrinks the plot. Right click AutoScale after resizing restores correct plot size.

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