-
Notifications
You must be signed in to change notification settings - Fork 782
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: add support for multiplier and offset notation #3827
Comments
Hi @zichen-ye, I think you are referring to the little numbers in the corner of the axes indicating an offset and/or multiplier: https://scottplot.net/cookbook/4.1/recipes/ticks_multiplier/ That feature is not currently in ScottPlot 5, but I'll use this issue to track adding it in 👍 |
While this feature could be added in, IMO it is much simpler just to use a custom tick formatter. As a result, you get far more control over how the ticks are formatted, such as if there is a threshold where scientific notation should be used, how it should be formatted (e.g. lowercase or capital Here is a sample. In this case, I only render in scientific notation if the largest tick on the plot is above 10,000, and I use C# format strings for the notation; see docs here. It does do some unnecessary computation of the string CustomFormatter(double position)
{
if (position == 0)
{
return "0";
}
var largestTickMagnitude = Math.Max(Math.Abs(myPlot.Axes.Left.Range.Min), Math.Abs(myPlot.Axes.Left.Max));
if (largestTickMagnitude <= 10_000)
{
// Too small to require scientific notation
return position.ToString(CultureInfo.CurrentCulture);
}
return $"{position:0.##e0}";;
} WinForms_Demo_zbjsOKZYEh.mp4In ScottPlot 4, there are a few edge cases which make this style of format difficult, such as dealing with large font sizes: That being said, it is simple enough to implement your own custom Axis now (inherit from |
Thanks a great point! Thanks for the example code you shared too. @zichen-ye is this strategy sufficient to meet your needs? |
Question: How do I implement 4.0's TickLabelNotation methods in ScottPlot5.0
ScottPlot Version: 5.0
The text was updated successfully, but these errors were encountered: