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

Tick marks on log scale are not always well distributed #83

Open
DiamondJim87 opened this issue Nov 15, 2023 · 14 comments
Open

Tick marks on log scale are not always well distributed #83

DiamondJim87 opened this issue Nov 15, 2023 · 14 comments
Assignees

Comments

@DiamondJim87
Copy link
Collaborator

I have a plot that has about 3.5 decades of log scale for the X axis. The initial tick marks every decade are great. But if I zoom in, the ticks don't smoothly/evenly cover the available space in a nice-to-read way. The attached screen shots show the issue pretty clearly.
original-plot
zoomed-in-plot
more-zoomed-in

@DiamondJim87
Copy link
Collaborator Author

Don't know if this is related, but our console has a bunch of messages like this that happen as I zoom in and out:

Nov 15, 2023 11:49:52 AM org.das2.qds.ops.Ops findex
WARNING: alarming extrapolation in findex is suspicious: count:1 uu:1.0 to 2047.0 vv:6.76430E6 to 6.76430E6
Nov 15, 2023 11:49:52 AM org.das2.qds.ops.Ops findex
WARNING: alarming extrapolation in findex is suspicious: count:1 uu:1.0 to 2047.0 vv:6.76430E6 to 6.76430E6
Nov 15, 2023 11:49:52 AM org.das2.qds.ops.Ops findex
WARNING: alarming extrapolation in findex is suspicious: count:1 uu:1.0 to 2047.0 vv:6.76430E6 to 6.76430E6
Nov 15, 2023 11:49:52 AM org.das2.qds.ops.Ops findex
W

@jbfaden jbfaden self-assigned this Nov 15, 2023
@jbfaden
Copy link
Member

jbfaden commented Nov 15, 2023

This code demos the bug in Autoplot:
plot( None, xlog=True, xrange='90.0 to 600.0', ylog=True, yrange='90.0 to 600.0' )

image

jbfaden pushed a commit that referenced this issue Nov 15, 2023
code to correct where step size for next decade was miscalculated.
@jbfaden
Copy link
Member

jbfaden commented Nov 15, 2023

I think this is fixed, and the code is more clear now. See

while ( m.value()<nextDecade*0.9999 ) { // kludge for real number fuzz...

@jbfaden jbfaden closed this as completed Nov 15, 2023
jbfaden pushed a commit that referenced this issue Nov 15, 2023
to create these directly.
jbfaden pushed a commit that referenced this issue Nov 15, 2023
code to correct where step size for next decade was miscalculated.
@jbfaden
Copy link
Member

jbfaden commented Nov 15, 2023

Actually I found a bug with the fix. I believe it's fixed now.

@jbfaden jbfaden reopened this Nov 15, 2023
@DiamondJim87
Copy link
Collaborator Author

It is definitely greatly improved! In most cases it makes useful choices. When straddling a decade boundary, there can still be cases like this. I would love it if there were one more tick on the right side, preferably right at the right-most boundary. I feel like such a prima donna for asking, but I'm thinking like my users now, who would be able to read this, but would like it better if they knew what number to ascribe to the right side of the plot.

Screenshot 2023-11-16 at 8 34 36 AM

@jbfaden
Copy link
Member

jbfaden commented Nov 16, 2023

I don't mind your asking, but it might be a little tricky. I think in this case, where it's using the LogLin algorithm, it should have the smarts to know that Lin (linear) is what's best here. Then you would have ticks at 90,95,100,105,110. A narrow range on log axis is essentially a linear axis, and linear axis ticks should be used. I think there's some mode where the log axis flips over to Lin, and maybe I was naive in thinking that the new LogLin could replace that mode.

Either way we need to have a bunch of tests identifying these conditions, and the most acceptable set of ticks.

@jbfaden
Copy link
Member

jbfaden commented Nov 16, 2023

Why not here:

range, 1000 pixels ticks
90-110 +5/5
90-400 90,95,100,150,200,250,300,350,400

It looks like you can edit it.

@jbfaden
Copy link
Member

jbfaden commented Nov 16, 2023

See the change here, which simply falls back to linear when the ratio of the max to the min is less than 3.5: 32c473c

@DiamondJim87
Copy link
Collaborator Author

This is really great -- this totally solves the odd corner cases and I think it works well most everything I tried. I do still have numbers running into each other at times on log scale, but this appears to be unrelated to these most recent changes:

Screenshot 2023-11-16 at 10 56 37 AM

@jbfaden
Copy link
Member

jbfaden commented Nov 16, 2023

Interesting, because that's using the old code. I wonder if the solution is to allow non-uniform ticks. I always figured it would get confusing if the ticks didn't immediate jump out as having log spacing. I wonder what it would look like to have 100,150,200,250,300,350,400,500,600,700,800,900,1000/5:

image

@jbfaden
Copy link
Member

jbfaden commented Nov 16, 2023

Another goal I've got with all of this is to have a nice way of expressing the algorithm used, so that you can force it. For example, we* could have +50,+100/5 meaning it could choose from either spacing.

(*) See how I did that, you are part of the solution team now...

@VoyagerPWS
Copy link
Member

The algorithm essentially just breaks "awkward" log intervals into sub-intervals, right? (Too-crowded bumps the scale up and too sparse bumps the scale down.) Also, an important measure to take into account for axes is the size in M.

@jbfaden
Copy link
Member

jbfaden commented Nov 16, 2023

Larry, yes, there's another thing I need to do with this algorithm. Most of the algorithms account for the font size, but I think this one doesn't do that. Thanks for reminding me!

@jbfaden
Copy link
Member

jbfaden commented Nov 28, 2023

Also I noticed *1E2, which should skip every other decade, draws minor ticks for the first decade but not for the second.

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

No branches or pull requests

3 participants