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
Tick mark label sizes are incorrectly calculated resulting in a poor layout #699
Comments
Hello, since it's a visual issue a screenshot would help a lot in understanding or diagnosing your issue. If possible, the relevant code would also be a plus. If you're plotting sensitive data then a screenshot of just the affected axis would be fine, or an example with the same issue but meaningless data. |
Certainly. My original code was part of a much larger app and would have been difficult to easily summarize. However, I have been able to duplicate the issue in a much smaller app. My xaml:
Code behind:
Screenshot: |
I should probably also mention that I am using version 4.1.3-beta. |
Thank you, for the time being using The arguments are all optional, you can set only left padding like this: Here is the code for https://github.com/ScottPlot/ScottPlot/blob/master/src/ScottPlot/Plot/Plot.Axis.cs#L102-L111 |
Thanks! I can confirm that setting
This issue aside, this is an impressive application. Kudos to all who have been working on it. |
I don't think I know what you mean, I don't know how you would have two left axes.
Yes, this should probably use |
With respect to the second issue, I agree that this is a fairly easily solved trig problem. But with respect to the first issue, however, ScottPlot has the ability to add additional Y-Axes via the |
Hi @MisterRedactus, thank you so much for reporting this! The axis sizes should be frequently recalculated to accommodate the ticks and labels. It looks like this is no longer happening, and the simplest way to demonstrate this is to zoom out on some of the cookbook examples:
EDIT: This broke between versions 4.1.2 and 4.1.3 |
Excellent! I'll be looking forward to your latest update. And again, I need to mention that this is a terrific app. You've done a lot of great work! |
Thanks for the encouragement @MisterRedactus! I figured out that the problem is caused by these two lines added in 2cdeb10 which attempted to improve the calculation of label dimensions for rotated ticks. I'm guessing the formula is wrong (or perhaps is only right for horizontal, but not vertical axes). For an immediate fix, comment-out these two lines: ScottPlot/src/ScottPlot/Renderable/Axis.cs Lines 380 to 381 in 2cdeb10
|
@swharden The issue is that the formula is only correct for horizontal axes, the problem is the use of the sine ratio, sine will give the vertical displacement, which only matters on the horizontal axis. The solution is to have an if statement that checks which edge it is on and uses sine or cosine based on that. Although since vertical axes don't currently support tick label rotation (and cos 0 = 1) you don't actually need trig. In #706 I addressed this, my code looked like this: switch (Edge)
{
case Edge.Top:
case Edge.Bottom:
sizeNeeded = Math.Min(maxWidth, maxHeight) + diff * (float)Math.Sin(AxisTicks.TickLabelRotation * Math.PI / 180);
break;
case Edge.Left:
case Edge.Right:
sizeNeeded = Math.Min(maxWidth, maxHeight) + diff * (float)Math.Cos(AxisTicks.TickLabelRotation * Math.PI / 180);
break;
} Feel free to adapt my solution if you'd like, I know not everyone is a fan of fall-through switch statements. |
@Benny121221, thanks for pointing that out! I've been going through issues bottom-to-top and I hadn't looked deep into #706 yet, and I now see that you figured out this error and offered a solution. Thanks so much! I think I'll move toward all axes supporting all rotations. Previously only the lower X axis supported it, but this was because of laziness. I'll modify #706 as needed to try to support all axes and merge it in. Thanks for solving @MisterRedactus problem too! |
Additional refactoring is still required (see TODO comment) Discussion in ScottPlot#706 and ScottPlot#699
Additional refactoring is still required (see TODO comment) Discussion in ScottPlot#706 and ScottPlot#699
This has been fixed by @Benny121221 in #708. In addition to the fix, rotated vertical axis tick labels are now supported. I'll publish a package on NuGet later today. Thanks for pointing-out this bug @MisterRedactus! I'm glad to see it's fixed now. |
I am having an issue with a plot cast as SignalPlotXY. Everything works well, but the Y-Axis label is on top of the Y-Axis tick labels, which are about 6-7 places in length. Is this a gap in my understanding or a bug, and, if the former, how do I address this?
The text was updated successfully, but these errors were encountered: