垂直线axvline在matplotlib中loglog plot中的线位置错误

2024-10-01 13:27:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我在matplotlib的loglog图中使用axvline绘制垂直线时遇到了一个问题。在

第一个问题是垂直线没有出现在正确的位置。在

第二个可能相关的问题是,当我放大或平移绘图时,垂直线只是停留在原位,并且没有通过平移(滑动绘图)或放大到绘图进行适当的转换。在

我的代码如下所示:

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

不幸的是,黑色/灰色垂直线未显示在0.01处,而是介于0.01和0.1之间(其他垂直线也不在正确位置):

enter image description here

另外,现在如果我放大图像,数据会适当放大,但垂直线保持不变。在

其他信息:

  • Matplotlib 1.5.1版
  • Python 3.5.1
  • ipython笔记本4.0.4
  • mpld3公司

我尝试升级到matplotlib 1.5.3,但是问题没有改变。在


Tags: importtrue绘图inputoutputmatplotlibas绘制