问题
I have a problem using axvline to plot vertical lines in the loglog plot of matplotlib.
The first problem is that the vertical lines do not appear at the right location.
The second problem, possibly related is that when I zoom in or translate the plot, the vertical lines just stay in place and are not appropriately transformed by the translation (sliding the plot) or zooming into to the plot.
My code looks as follows:
import numpy as np
import matplotlib.pyplot as plt
f, axes = plt.subplots(1, sharex=True, sharey=True)
axes.loglog(frqs,F_in,label="Input")
axes.loglog(frqs,F_out,label="Output")
axes.autoscale(enable=True, axis='x', tight=True)
axes.set_title("Input and Output Spectrum")
axes.legend()
axes.axvline(x=0.01, color='k')
Unfortunately the black/grey vertical line does not show up at 0.01 but somewhere between 0.01 and 0.1 (the other vertical lines are also not in the right location):
In addition, now if I zoom into the image, the data is zoomed appropriately but the vertical lines are left unchanged.
Additional Info:
- Matplotlib 1.5.1
- Python 3.5.1
- ipython-notebook 4.0.4
- mpld3
I tried upgrading to matplotlib 1.5.3 but that leaves the problem unchanged.
来源:https://stackoverflow.com/questions/39827697/vertical-line-axvline-plots-line-in-wrong-position-in-loglog-plot-in-matplotlib