Skip to content

SetAxisLimits accepts invalid limits #2327

@mjpz

Description

@mjpz

Hi Scott, thank you for this great library!

Bug Report

Issue: (Bug description goes here)

SetAxisLimits accepts AxisLimits with max values less then min values, the generated plot is invalid

Reproducing: (What do others have to do to reproduce the bug?)

Generate the plot

OHLC[] ohcls = DataGen.RandomStockPrices(null, 100);
candlePlot = formsPlot1.Plot.AddCandlesticks(ohcls);
candlePlot.Sequential = true;

Works as expected

var al = new AxisLimits(0, 100, 150, 400);
formsPlot1.Plot.SetAxisLimits(al);
formsPlot1.RenderRequest();
formsPlot1.Plot.SaveFig("a.png");

a

yMax < yMin

var al = new AxisLimits(0, 100, 400, 150);
formsPlot1.Plot.SetAxisLimits(al);
formsPlot1.RenderRequest();
formsPlot1.Plot.SaveFig("b.png");

b

xMax < xMin

var al = new AxisLimits(100, 0, 150, 400);
formsPlot1.Plot.SetAxisLimits(al);
formsPlot1.RenderRequest();
formsPlot1.Plot.SaveFig("c.png");

c

Expected Behavior
SetAxisLimits throws ArgumentException

System Details

  • ScottPlot Version: 4.1.60
  • Operating System: Windows 10
  • Application Type: WinForms
  • .NET Version: .Net 7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGunexpected behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions