Skip to content

Removing a ColorBar doesn't reset the YAxis PixelSizeMinimum #1732

@ccopsey

Description

@ccopsey

Bug Report

YAxis can refer to YAxis or YAxis2 where relevent...

Issue: Adding a ColorBar to a plot increases the YAxis PixelMinimumSize. Subsequently removing the ColorBar doesn't reduce this value and consequently leaves a large margin between the YAxis and the edge of the bitmap.

The convenience method Plot.AddColorbar() calls YAxis.SetSizeLimit(min: space) but there is no equivalent method of resetting this value. The workaround is to manually call YAxis.SetSizeLimit(min: 5) but this is fragile. A public method to ResetSizeLimit() would be a good start.

Reproducing:

[Test]
public void Test()
{
    var plt = new ScottPlot.Plot();
    var bmp1 = TestTools.GetLowQualityBitmap(plt);
    var cb = plt.AddColorbar();
    plt.Remove(cb);
    var bmp2 = TestTools.GetLowQualityBitmap(plt);
    var before = new MeanPixel(bmp1);
    var after = new MeanPixel(bmp2);
    Assert.That(after.IsEqualTo(before));
}

System Details

  • ScottPlot Version: SHA 3581f8c
  • Operating System: Windows 10
  • Application Type: console, WPF
  • .NET Version: .NET 5.0/6.0

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