Skip to content

Plot: add figure and data border#5024

Merged
swharden merged 7 commits intoScottPlot:mainfrom
CoderPM2011:feat/FigureBorder
Aug 8, 2025
Merged

Plot: add figure and data border#5024
swharden merged 7 commits intoScottPlot:mainfrom
CoderPM2011:feat/FigureBorder

Conversation

@CoderPM2011
Copy link
Contributor

This PR mainly adds border style attributes and border rendering functions to Plot.
Here are some related adjustments:

  1. Use the Render() method of the Sync object to uniformly call RenderManager.Render(), avoiding distributed rendering processing.
  2. Added a conversion method from SKRectI to PixelRect.
  3. Since LocalClipBounds in WinForm returns a range that exceeds the rendering range, the boundaries of the Render(IMultiplot, SKSurface) method have been changed from LocalClipBounds to DeviceClipBounds to ensure that the rendered content matches the device's clip range.

resolve #4854

demo result

  1. In WinForm
    image

  2. Save to image file
    plot1
    plot2

demo code

var multiplot = formsPlot1.Multiplot;
formsPlot1.Multiplot = multiplot;

multiplot.AddPlots(2);
Plot plot1 = multiplot.Subplots.GetPlot(0);
Plot plot2 = multiplot.Subplots.GetPlot(1);

plot1.BorderStyle.Pattern = LinePattern.Dashed;
plot1.BorderStyle.Color = Colors.Red.WithOpacity(0.5);
plot1.BorderStyle.Width = 20;

plot2.BorderStyle.Color = Colors.Black;
plot2.BorderStyle.Width = 1;

plot1.Add.Signal(Generate.Sin());
plot2.Add.Signal(Generate.Cos());

plot1.SavePng("plot1.png", 400, 300);
plot2.SavePng("plot2.png", 400, 300);

CoderPM2011 and others added 5 commits August 3, 2025 23:02
The boundary of the Render(IMultiplot, SKSurface) method has been changed from LocalClipBounds to DeviceClipBounds to ensure that the rendered content fits within the device's clipping range
@swharden
Copy link
Member

swharden commented Aug 8, 2025

This is great @CoderPM2011!

I'm adding a feature to outline the data area too
image

I'm also refining the rendering system a bit, but I'll merge in a few minutes 🚀

@swharden
Copy link
Member

swharden commented Aug 8, 2025

It seems that 1 pixel around the edges of SKControl is not rendered. To ensure all edges of the rectangle are visible, the drawing area should be inset by 1 pixel

This may still be the case ... but I'm inclined to merge how it is and let somebody ask for it lol 🤪

Thanks again for this PR! 🤩

@swharden swharden changed the title Plot: Add border styles and rendering features Plot: add figure and data border Aug 8, 2025
@swharden swharden enabled auto-merge (squash) August 8, 2025 01:04
@swharden swharden merged commit 3de6475 into ScottPlot:main Aug 8, 2025
3 checks passed
@CoderPM2011 CoderPM2011 deleted the feat/FigureBorder branch August 8, 2025 01:07
@CoderPM2011
Copy link
Contributor Author

It seems that 1 pixel around the edges of SKControl is not rendered. To ensure all edges of the rectangle are visible, the drawing area should be inset by 1 pixel

This may still be the case ... but I'm inclined to merge how it is and let somebody ask for it lol 🤪

Thanks again for this PR! 🤩

Maybe fixed: switched to DeviceClipBounds (0,0,w,h) - LocalClipBounds can sometimes exceed that like (-1,-1,w+1,h+1). 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Figure: add option to allow a border

2 participants