Support for patterned bar charts#555
Conversation
|
I did notice this line: https://github.com/Benny121221/ScottPlot/blob/9cc49afe59a3964a2670536a97cdd45c573bfe18/src/ScottPlot/Renderable/Legend.cs#L145L146 For plots where this displays a line this makes sense. However bar charts in the legend are represented by a rectangle, which means for solid-coloured charts it is drawing a wide line instead of a rectangle. I don't think it's likely to cause any issues, however when I was looking to extend it to support non-solid brushes I ignored it as I assumed it would be elsewhere, because I expected rectangles to be drawn by |
|
Hi @Benny121221, |
|
Hey @Benny121221, this is awesome! I look forward to reviewing this PR in detail soon. In the mean time, I do agree with @StendProg about minimizing reliance on direct System.Drawing calls where possible. I'm trying to eventually remove the System.Drawing dependency out of ScottPlot and allow ScottPlot to display graphics using different rendering systems (e.g., SkiaSharp + OpenGL, #521), so anything we can do now to abstract those calls away will help this transition later.
|
|
... extending the previous comment, I'd love to use a custom enum instead of Such an enum could have a In reviewing System.Drawing.Drawing2D.HatchStyle docs I can see there are many, many hatch styles! Perhaps we can just support a few of the ones that make most sense for plotting, and implement them now using System.Drawing calls and later re-implement them using other drawing technologies when the time comes. A good place for those hatch styles to live is next to the line styles enum in Style.cs: You can make this change if you want, or I'll do it some time between now and merge. Thanks again for this PR! The screenshot looks awesome, and again I look forward to reviewing it in more detail soon. |
|
It now uses an enum which looks like this: public enum HatchStyle
{
None,
StripedUpwardDiagonal,
StripedDownwardDiagonal,
StripedWideUpwardDiagonal,
StripedWideDownwardDiagonal,
LargeCheckerBoard,
SmallCheckerBoard,
LargeGrid,
SmallGrid,
DottedDiamond
}There is a corresponding |
previously it wasn't clear by looking at the bar which color was the fill and which was the hatch
|
This PR solves issue #552 MatplotlibI thought I'd mention I was curious how matplotlib names their hatch styles so I looked it up and it seems they use strings to define hatch styles. Some of their styles get pretty advanced too: Interestingly their diagonal hatches are GDI |
so we can use the same property name in other plottables in the future
bring property names consistent with new box property names
now regular (non-hatched) bar graph legend items have an outline to match the bar graph


New contributors should review CONTRIBUTING.md
Purpose:
#552
New functionality (code):
Provide a code example demonstrating new functionality achieved with this pull request (if applicable):
New functionality (image):

If this pull request changes how a plot is rendered, provide an image or screenshot demonstrating the new functionality:
Autoformat your code:
The build will fail if your code is not auto-formatted. Auto-format your code in Visual Studio, or from the console using these commands: