question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WpfPlot ignores layout padding if defined during window initialization

See original GitHub issue

Describe the bug Rendering a WPF plot includes an unnecessary and undesirable margin that cannot be removed (or at least I couldn’t find a way to remove it).

To Reproduce To reproduce the problem, create a WPF project and add a window with a single WpfPlot element like this:

<Window>
    <Grid>
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
         <WpfPlot x:Name="testWpfPlot" Padding="0"/>
    </Grid>
</Window>

Then, configure the plot to render some signal or any plottable and then remove the ticks and attempt to change layout to remove any additional padding or extra space around the figure.

testWpfPlot.plt.Clear(scatterPlots: true);
testWpfPlot.plt.PlotBar(xs: new double[100], ys: new double[100],    // can generate some random data and plot 
            barWidth: 2, 
            xOffset: -0.5, 
            fillColor: System.Drawing.Color.SlateGray,
            outlineWidth: 0,
            label: "test");
testWpfPlot.plt.Grid(xSpacing: 2);
testWpfPlot.plt.Style(ScottPlot.Style.Gray2);
testWpfPlot.plt.AxisAuto();
testWpfPlot.plt.Ticks(displayTickLabelsX: false, displayTickLabelsY: false, displayTicksX: false, displayTicksY: false);
testWpfPlot.plt.TightenLayout(padding: 0);
testWpfPlot.plt.Frame(false);

The expectation is that the plot would render using the full available space without leaving any additional space

Screenshots Screen Shot 2020-09-16 at 3 56 05 PM

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
swhardencommented, May 10, 2022

@sopgenorth you may also find use in your plot’s Frameless() method

https://scottplot.net/cookbook/4.1/category/axis-and-ticks/#frameless-plots

1reaction
swhardencommented, May 10, 2022

Hi @sopgenorth

Is there a newer recommended way of achieving this same tight layout?

Indeed! Try calling your plot’s Layout() method. Pay close attention to each of the arguments, including padding.

I created issue #1841 with the goal of adding a cookbook section to make these features easier to discover 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

WpfPlot ignores layout padding if defined during window ...
It looks like in order to preserve the "no padding" setting I needed to call TightenLayout(padding: 0) before the Render call each time....
Read more >
wpf - Window.Margin & Window.Padding don't work
I have a whole project that all its windows are set to a style, I want to set this properties (or other) in...
Read more >
ScottPlot 4.0.47 Cookbook
The strategy is to plot it on a linear horizontal axis (not a DateTime axis) and then to come back later and define...
Read more >
Alignment, Margins, and Padding Overview - WPF .NET ...
This topic discusses four of the most important properties: HorizontalAlignment, Margin, Padding, and VerticalAlignment. The effects of these ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found