axis
d3 tick marks on integers only
The proper solution is to retrieve ticks using .ticks() method, filter them to keep only integers and pass them to .tickValues(): const yAxisTicks = yScale.ticks() .filter(tick => Number.isInteger(tick)); const yAxis = d3.axisLeft(yScale) .tickValues(yAxisTicks) .tickFormat(d3.format(‘d’)); For completeness here is explanation why other solutions are bad: @BoomShakalaka solution uses .tickSubdivide() method, which no longer exists. @cssndrx and … Read more
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
How to reverse axis values when using plotly?
You are probably looking for layout(xaxis = list(autorange = “reversed”).
How to display all minor tick marks on a semi-log plot
solution for matplotlib >= 2.0.2 Let’s consider the following example which is produced by this code: import matplotlib.pyplot as plt import matplotlib.ticker import numpy as np y = np.arange(12) x = 10.0**y fig, ax=plt.subplots() ax.plot(x,y) ax.set_xscale(“log”) plt.show() The minor ticklabels are indeed gone and usual ways to show them (like plt.tick_params(axis=”x”, which=”minor”)) fail. The first … Read more
How to change border width of a matplotlib graph
Maybe this is what you are looking for? It sets the value globally. import matplotlib as mpl mpl.rcParams[‘axes.linewidth’] = 0.1
Drawing average line in histogram
You can use plot or vlines to draw a vertical line, but to draw a vertical line from the bottom to the top of the y axis, axvline is the probably the simplest function to use. Here’s an example: In [80]: import numpy as np In [81]: import matplotlib.pyplot as plt In [82]: np.random.seed(6789) In … Read more
how to turn on minor ticks only on y axis
Nevermind, I figured it out. ax.tick_params(axis=”x”, which=”minor”, bottom=False)