Skip to content

Grid: add support for alternating fill colors#4201

Merged
swharden merged 5 commits intoScottPlot:mainfrom
CoderPM2011:feat/GridStyle-Alternating-BgColor
Sep 1, 2024
Merged

Grid: add support for alternating fill colors#4201
swharden merged 5 commits intoScottPlot:mainfrom
CoderPM2011:feat/GridStyle-Alternating-BgColor

Conversation

@CoderPM2011
Copy link
Contributor

@CoderPM2011 CoderPM2011 commented Sep 1, 2024

resolve #4022

Sample

result image

image

sample code

myPlot.Grid.XAxisStyle.AlternatingColor = Colors.Yellow.WithOpacity(0.3);
myPlot.Grid.YAxisStyle.AlternatingColor = Colors.Red.WithOpacity(0.3);

@swharden
Copy link
Member

swharden commented Sep 1, 2024

Thanks for this PR @CoderPM2011! I'm refining it a bit and the results are looking awesome 🚀

// add a green data line
var sig = myPlot.Add.Signal(Generate.SquareWaveFromSines());
sig.LineWidth = 3;
sig.Color = new("#2b9433");
sig.AlwaysUseLowDensityMode = true;

// give the plot a dark background with light text
myPlot.FigureBackground.Color = new("#1c1c1e");
myPlot.Axes.Color(new("#888888"));

// shade regions between major grid lines
myPlot.Grid.XAxisStyle.FillColor1 = new Color("#888888").WithAlpha(10);
myPlot.Grid.YAxisStyle.FillColor1 = new Color("#888888").WithAlpha(10);

// set grid line colors
myPlot.Grid.XAxisStyle.MajorLineStyle.Color = Colors.White.WithAlpha(15);
myPlot.Grid.YAxisStyle.MajorLineStyle.Color = Colors.White.WithAlpha(15);
myPlot.Grid.XAxisStyle.MinorLineStyle.Color = Colors.White.WithAlpha(5);
myPlot.Grid.YAxisStyle.MinorLineStyle.Color = Colors.White.WithAlpha(5);

// enable minor grid lines by defining a positive width
myPlot.Grid.XAxisStyle.MinorLineStyle.Width = 1;
myPlot.Grid.YAxisStyle.MinorLineStyle.Width = 1;

GridAlternatingDarkMode

@swharden swharden changed the title GridStyle: Added AlternatingColor Grid: add support for alternating fill colors Sep 1, 2024
@swharden swharden merged commit 7eec2cf into ScottPlot:main Sep 1, 2024
@CoderPM2011 CoderPM2011 deleted the feat/GridStyle-Alternating-BgColor branch September 2, 2024 12:46
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.

Alternately color the spaces between the grids

2 participants