d3 axis labeling

Axis labels aren’t built-in to D3’s axis component, but you can add labels yourself simply by adding an SVG text element. A good example of this is my recreation of Gapminder’s animated bubble chart, The Wealth & Health of Nations. The x-axis label looks like this: svg.append(“text”) .attr(“class”, “x label”) .attr(“text-anchor”, “end”) .attr(“x”, width) .attr(“y”, … Read more

Remove plot axis values

Remove numbering on x-axis or y-axis: plot(1:10, xaxt=”n”) plot(1:10, yaxt=”n”) If you want to remove the labels as well: plot(1:10, xaxt=”n”, ann=FALSE) plot(1:10, yaxt=”n”, ann=FALSE)

Aligning rotated xticklabels with their respective xticks

You can set the horizontal alignment of ticklabels, see the example below. If you imagine a rectangular box around the rotated label, which side of the rectangle do you want to be aligned with the tickpoint? Given your description, you want: ha=”right” n=5 x = np.arange(n) y = np.sin(np.linspace(-3,3,n)) xlabels = [‘Ticklabel %i’ % i … Read more