Create a D3 axis without tick labels

I’m just going to leave this here since people are likely to end up on this question. Here are the different ways you can easily manipulate a D3 axis.

  • Without any ticks or tick labels:

    d3.svg.axis().tickValues([]);
    

    No line or text elements are created this way.

  • Without ticks and with tick labels:

    d3.svg.axis().tickSize(0);
    

    The line elements are still created this way.

    You can increase the distance between the tick labels and the axis with .tickPadding(10), for example.

  • With ticks and without tick labels:

    d3.svg.axis().tickFormat("");
    

    The text elements are still created this way.

Leave a Comment