Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
26
rated 0 times [  27] [ 1]  / answers: 1 / hits: 45675  / 12 Years ago, sun, december 2, 2012, 12:00:00

I'm using (the excellent) D3.js to generate some plots, and I can't find a way to remove the end ticks from the x and y axis.


Take the y-axis for example.


When the end tick value coincides with a label, I'm ok with having it.


But when the last round label is below the end of the plot, I get two ticks, one for the last rounded label and one above it at the end of the y-axis.


I don't want this end-tick visible, because I find the fact that it appears in less than the regular interval between labels distracting.


See here for an example of what I'm describing, the ticks at 0 and 15 are the end ticks:


15 ─┐ 
|
10 _|
|
5 _|
|
0 ─┤──────

Any tips?


P.S As a response suggested, I could set the ticks explicitly. But I like the convenience of the implicit generated ticks, just don't want unlabelled ticks to pollute the axis. So an ideal solution (if exists) would also take than into account.


More From » d3.js

 Answers
36

The axis.tick* functions can help you there. You have a number of possibilities to prevent the behaviour you're describing. You could set the ticks explicitly using the tickValues() function. Or you could set the size of the end ticks to 0 using tickSize(). You can also control the underlying scale using the ticks() function.



Depending on your particular scenario, one of these options may make more sense than the others.


[#81664] Friday, November 30, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
berenices

Total Points: 104
Total Questions: 106
Total Answers: 106

Location: Spain
Member since Thu, Dec 23, 2021
2 Years ago
;