Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axes: improve sharpness of axis lines, tick marks, and grid lines #3976

Merged
merged 9 commits into from
Jun 25, 2024
Merged

Conversation

bforl
Copy link
Contributor

@bforl bforl commented Jun 21, 2024

Allow users to be able to disable antialiasing on grid lines and ticks, which to my mind creates a more pleasing graph as the aa lines look blurry. The defaults have been left as they were, so this is an "opt into" change.

Before
AntiAlliased

After (with the configuration code below)
Aliased

     WpfPlot1.Plot.Axes.Left.FrameLineStyle.AntiAlias = false;
     WpfPlot1.Plot.Axes.Top.FrameLineStyle.AntiAlias = false;
     WpfPlot1.Plot.Axes.Right.FrameLineStyle.AntiAlias = false;
     WpfPlot1.Plot.Axes.Bottom.FrameLineStyle.AntiAlias = false;

     WpfPlot1.Plot.Grid.XAxisStyle.MajorLineStyle.AntiAlias = false;
     WpfPlot1.Plot.Grid.YAxisStyle.MajorLineStyle.AntiAlias = false;

     WpfPlot1.Plot.Axes.Left.MajorTickStyle.IsAntialias = false;
     WpfPlot1.Plot.Axes.Left.MinorTickStyle.IsAntialias = false;

     WpfPlot1.Plot.Axes.Bottom.MajorTickStyle.IsAntialias = false;
     WpfPlot1.Plot.Axes.Bottom.MinorTickStyle.IsAntialias = false;

I highly recommend the ZoomIt app for being able to investigate these kinds of issues.
https://learn.microsoft.com/en-us/sysinternals/downloads/zoomit

@swharden
Copy link
Member

Hi @bforlgreen, fantastic observation! Thanks so much for this PR!

I'm liking what I'm seeing so much, I'm considering disabling anti-aliasing by default. Axis frames, axis lines, and tick marks look best when they are "crisp". I'll take a closer look and merge this in a few minutes! 🚀

@swharden
Copy link
Member

I'm noticing a few small artifacts when frame anti-aliasing is disabled... I'll fix those two in this PR before I merge

image

@swharden
Copy link
Member

This looks so much better! Also I'm loving ZoomIt - thanks for the tip! 🚀

AntiAlias = false AntiAlias = true
image image

@swharden swharden changed the title Add aliasing options to grid/ticks Axes: improve sharpness of axis lines, tick marks, and grid lines Jun 25, 2024
@swharden swharden enabled auto-merge (squash) June 25, 2024 01:00
@swharden swharden merged commit 305fe4d into ScottPlot:main Jun 25, 2024
2 of 3 checks passed
@bforl
Copy link
Contributor Author

bforl commented Jun 25, 2024

Great!

Yes, my observations are that its nice to have AA disabled for anything that you know will be a straight line.

I've done this for my bar charts too.

However, it's not a silver bullet, as it really depends on what you're showing and if you have enough pixels to form consistent spacing between elements. For example, lots of bars in a chart when zoomed out (where there isn't much space to render them) can look worse with AA disabled if the maths doesn't work out evenly. So you kind of want it dynamic with some heuristic

KroMignon added a commit to KroMignon/ScottPlot that referenced this pull request Jun 26, 2024
* upstream/main:
  Fix interaction of axis panels when scale factor is more than 1 (ScottPlot#3994)
  Added ResetMinAndMaxValues() to DataLoggerSource.cs (ScottPlot#3993)
  CoordinateLine: add constructor overloads (ScottPlot#3987)
  Colormap.GetColors() (ScottPlot#3983)
  Added a constructor overload that accepts List<Coordinates> (ScottPlot#3982)
  Signal: improve support for IReadOnlyList<T> (ScottPlot#3978)
  Axes: improve sharpness of axis lines, tick marks, and grid lines (ScottPlot#3976)
  adding console write file name function (ScottPlot#3965)
  Color.ToColor()
  Sandbox: extend minimal API
  Sandbox: Create .NET API project
  SVG XML Updates (ScottPlot#3957)
  Repeat render if changes are made in invoked events (ScottPlot#3952)
  CI: autoformat
  Experimental DataLogger2 using a `CircularBuffer<T>` (ScottPlot#3946)
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.

2 participants