Here they describe how to display the axis numbers in binary using StrMethodFormatter
.
The code described there is:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import StrMethodFormatter
fig, ax = plt.subplots()
ax.yaxis.set_major_formatter(StrMethodFormatter("{x:07b}"))
ax.yaxis.set_ticks(np.arange(0, 110, 10))
x = np.arange(1, 10, 0.1)
plt.plot(x, x**2)
plt.show()
So, he is setting the y_ticks. Is there a way to display the axis in binary without setting the y ticks?
When I remove ax.yaxis.set_ticks(np.arange(0,110,10))
, then it throws the error: ValueError: Unkown format code 'b' for object of type 'float'
For my own plot all the points are integers, yet I get the same error. Does anyone know how to display the axis in binary without having to set y ticks?