I would like to produce some plot over the frequencies. I want to have an x-axis with superscript notation like in here.
In addition I need vertical lines with vertical annotation separate kilo and mega Hz.
import numpy as np
import matplotlib.pyplot as plt
band = np.linspace(0,10**12,100)
y = band
plt.plot(band,y)
plt.xlabel('Frequencies')
plt.vlines(10**3, min(y), max(y),colors = 'black', label = 'kilo Hz')
plt.vlines(10**6, min(y), max(y),colors = 'black', label = 'mega Hz')
plt.legend()
plt.show()
I tried use ticker but can't figure it out how to set up it. I tried to follow some examples but got error like AttributeError: 'Figure' object has no attribute 'ticklabel_format'
Already spend quite a lot of time on it and don't know how to move forward.
In general I need the x-axis formatted in the similar way, than if plt.xscale('log')
but I want to keep linear scale.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…