Skip to content

SP4: new plot type for drawing rectangles #2866

@dpieve

Description

@dpieve

Feature Suggestion

Feature description:

Possibility to add rectangles to a Plot.
It could be an interesting feature to highlight a specific area.

Code example:

var plt = new ScottPlot.Plot(600, 400);
plt.AddSignal(DataGen.Sin(51));
var rect = plt.AddRectangle(x, y, width, height); 

I'm using the AddPolygon to add a rectangle. I'll leave it here as an example.

/// <summary>
/// Displays a rectangle starting from the top-left X/Y coordinates.
/// </summary>
private Polygon AddRectangle(double x, double y, double width, double height, Color? fillColor = null, double lineWidth = 0, Color? lineColor = null)
{
    double[] xs = { x, x + width, x + width, x };
    double[] ys = { y, y, y - height, y - height };

    return plt.AddPolygon(xs, ys, fillColor, lineWidth, lineColor);
 }

I think this feature doesn't exist. Let me know if it does.

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