2

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):

enter image description here

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.

Community
  • 1
  • 1
patapouf_ai
  • 17,605
  • 13
  • 92
  • 132
  • 1
    Cannot reproduce your problem using matplotlib version 1.5.0 (although log transforming the axes has always been a source of numerous bugs in matplotlib, so I was not surprised). – Paul Brodersen Oct 03 '16 at 10:10
  • I have matplotlib 1.5.1. – patapouf_ai Oct 03 '16 at 10:45
  • Other possibly relevent points is that I am doing this in an ipython notebook and I have mpld3 activated. – patapouf_ai Oct 03 '16 at 10:47
  • 1
    Check if it is an mpl3d problem and file a bug report. It sounds like the axvline position is not updated on resizing the figure (the initial position is presumably off because there already was one resize operation going from display (default matplotlib drawing space) to mpl3d (presumably living in browserland)). – Paul Brodersen Oct 03 '16 at 13:18
  • @Paul, you are correct. If I dissable mpl3d, the lines are in the right position. If you want to write up an answer I will accept it. Where should I write a bug report? – patapouf_ai Oct 03 '16 at 13:52
  • It seems to be a bug, so this question will hopefully soon lose its relevance, so don't bother with accepting an answer. The github for mpld3 seems to be at https://github.com/mpld3/mpld3. Best of luck. – Paul Brodersen Oct 03 '16 at 14:15
  • Hopefully. Thanks. – patapouf_ai Oct 03 '16 at 14:16

0 Answers0