axis-labels
matplotlib: Aligning y-axis labels in stacked scatter plots
You can use the set_label_coords method. import matplotlib.pylab as plt import random import matplotlib.gridspec as gridspec random.seed(20) data1 = [random.random() for i in range(10)] data2 = [random.random()*1000 for i in range(10)] gs = gridspec.GridSpec(2,1) fig = plt.figure() ax = fig.add_subplot(gs[0]) ax.plot(data1) ax.set_ylabel(r’Label One’, size =16) ax.get_yaxis().set_label_coords(-0.1,0.5) ax = fig.add_subplot(gs[1]) ax.plot(data2) ax.set_ylabel(r’Label Two’, size =16) ax.get_yaxis().set_label_coords(-0.1,0.5)
Rotating axes label text in 3D
As a workaround, you could set the direction of the z-label manually by: ax.zaxis.set_rotate_label(False) # disable automatic rotation ax.set_zlabel(‘label text’, rotation=90) Please note that the direction of your z-label also depends on your viewpoint, e.g: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fg = plt.figure(1); fg.clf() axx = [fg.add_subplot(4,1,1+i, projection=’3d’) for i in range(4)] … Read more
Show decimal places and scientific notation on the axis
This is really easy to do if you use the matplotlib.ticker.FormatStrFormatter as opposed to the LogFormatter. The following code will label everything with the format ‘%.2e’: import numpy as np import matplotlib.pyplot as plt import matplotlib.ticker as mtick fig = plt.figure() ax = fig.add_subplot(111) x = np.linspace(0, 300, 20) y = np.linspace(0,300, 20) y = … Read more
How to set axis ticks in multiples of pi (Python) (matplotlib)
This is inspired by Python Data Science Handbook, although Sage attempts to do without explicit parameters. EDIT: I’ve generalized this to allow you to supply as optional parameters the denominator, the value of the unit, and the LaTeX label for the unit. A class definition is included if you find that helpful. import numpy as … Read more
d3.js: Align text labels between ticks on the axis
I ended up with one of the Lars Kotthoff’s advices. Every time when I call(axis) I also adjust text labels. Here is simplified code: function renderAxis() { axisContainer .transition().duration(300) .call(axis) // draw the standart d3 axis .call(adjustTextLabels); // adjusts text labels on the axis } function adjustTextLabels(selection) { selection.selectAll(‘.major text’) .attr(‘transform’, ‘translate(‘ + daysToPixels(1) / … Read more
How to limit d3.svg.axis to integer labels?
You should be able to use d3.format instead of writing your own format function for this. d3.svg.axis() .tickFormat(d3.format(“d”)); You can also use tickFormat on your scale which the axis will automatically use by default.
How can I rotate xticklabels in so the spacing between each xticklabel is equal? [duplicate]
The labels are centered at the tickmark position. Their bounding boxes are unequal in width and might even overlap, which makes them look unequally spaced. Since you’d always want the ticklabels to link to their tickmarks, changing the spacing is not really an option. However you might want to align them such the the upper … Read more
Rotate axis tick labels
This works for me: plt.xticks(rotation=90)