Add the ability to not call into collapse-ticks#41
Add the ability to not call into collapse-ticks#41evdubs wants to merge 1 commit intoracket:masterfrom
Conversation
… when trying to just have tick labels on the far y axis while keeping the ticks on the near y axis and allowing the grid to still be drawn
|
I'll need to add some documentation for this feature. |
|
I would like to know if there's either a way to display the near y axis ticks that I haven't figured out or if there's a more appropriate fix. |
|
I have only spend a small amount of time on this, and I didn't have time to figure out what My preference would be to find out if there is actually a bug in BTW, I'm not a maintainer, just a user of this package, the maintainers might have different opinions on this. |
|
I don't see a way to get unlabeled near-axis ticks and labeled far-axis ticks with the current plot. If there was a way to tell plot "use the right side as the near axis, not the left side", would that solve your problem? (I'm not sure how to implement that, but it seems like a clearer fix.) |
|
@bennn that would be a preferable solution. I only took this approach because it seemed to work and was relatively straight forward. |
|
I think the problem is that If You will find that the plot is rendered as intended if (define (same-label? t1 t2)
(and (string=? (tick-label t1) (tick-label t2))
(not (string=? (tick-label t1) "")))) |
|
Yes, if we have a parameter to make the new behavior opt-in (to avoid changing existing plots). Something like this: This is better to me because it's a smaller change. But I'd still prefer to have a parameter that makes the left side be the far axis. |
|
@bennn the parameter should already be opt-in, it just has a larger scope if you opt in rather than just taking effect within the same-label? check. Or am I misunderstanding something? |
|
@bennn I will take a look to see what the code change looks like to switch axes for being near/far. |
|
I think we understand each other
And to be clear I don't feel very strongly that |
|
Just to add my two cents to this conversation... I think the current behavior of With the current behavior, To further elaborate on this: disabling |
Whether or not it's a bug, I think we should keep the current behavior as the default --- so if a plot user upgrades to the next version of Racket, their old plots still look the same. |
|
ah! I just ran into a problem with Here's what the plot looks like on the current Here's what the plot looks like if I remove all calls to And here's what the plot looks like if I call @evdubs what do you think about changing this PR from 1 parameter to 6 parameters ( |
|
I can certainly do that. Do you think it's still worth investigating the whole "treat the far-x-axis as the near-x-axis" thing? |
|
That still seems useful, but this barchart experience made me realize that control over Leave it for a separate PR? |
|
Hi @Benn, your minor ticks are missing because they have the same label as the major ticks, and this is exactly what (define my-ticks
(ticks (λ (ax-min ax-max)
(define major-ticks
(for/list ((i (in-range 0 (log ax-max 10))))
(pre-tick (expt 10 i) #true)))
(define minor-ticks
(for*/list ((i (in-range 0 (exact-ceiling (log ax-max 10))))
(j (in-range 2 10 2)))
(pre-tick (* (expt 10 i) j) #false)))
(append minor-ticks major-ticks))
(lambda (ax-min ax-max pre-ticks)
(for/list ([pt (in-list pre-ticks)])
(if (pre-tick-major? pt)
(format "10~a" (integer->superscript (exact-floor (log (pre-tick-value pt) 10))))
(format "~a" (pre-tick-value pt)))))))And they will show up as you intended. This is with the code on the master branch. The changes I proposed to |
|
@alex-hhh thanks for this! I didn't realize the I'm still thinking parameters to disable |
|
Hi @bennn, I don't think that a For the first example, I think, some For the second example, I think the documentation for I also think the |
|
I'll make a pull request for the documentation for
That's ok with me as long as the fix doesn't change how existing plots render. (There should be a parameter or something to say "please don't collapse ticks with an empty label".) I still have the feeling we'll want to give control over collapse-ticks someday, but I can't argue with you that the examples we have now aren't super-motivating. |
|
I created PR #43 and I think that code change will be much more agreeable. |





This is most helpful when trying to just have tick labels on the far y axis while keeping the ticks on the near y axis and allowing the grid to still be drawn. Here is the code that can be used for testing
By changing
collapse-ticks?to#f, we can see all of the ticks on the near y axis and thetick-gridwill also be displayed.