Skip to content

Add equal scaling for x y axis #272

@gberrante

Description

@gberrante

Hi Scott,
thank you for this amazing work.

I would like to suggest to add a feature that enables the user to have the same scaling for both x y axis.

I tried to implement that by adjusting the axes limit from min(x,y) to max(x,y) and then using the aspect ratio of the plot and zoom out by the ratio the y axes. It works somehow but is not really a robust solution, the axis should be adjusted at any plot component resize. Another drawback that i did not solved yet is to re-center the plotted line in my case.

//equal axis scaling
double xmin = xarray.Min();
double xmax = xarray.Max();
double ymin = yarray.Min();
double ymax = yarray.Max();

double minimum = Math.Min(Math.Min(xmin,ymin),Math.Min(xmax,ymax));
double maximum = Math.Max(Math.Max(xmin, ymin), Math.Max(xmax, ymax));
this.axesXY.plt.Axis(minimum, maximum, minimum, maximum);
double Width = this.axesXY.plt.CoordinateToPixel(maximum, minimum).X- 
this.axesXY.plt.CoordinateToPixel(minimum,minimum).X;

double Height = this.axesXY.plt.CoordinateToPixel(minimum, maximum).Y - this.axesXY.plt.CoordinateToPixel(minimum, minimum).Y;

double ratio = Math.Abs(Width / Height);
this.axesXY.plt.AxisZoom(1,ratio);
this.axesXY.Render();

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