python plot 坐标轴范围_Python,Matplotlib,子图:如何设置轴范围?

1586010002-jmsa.png

How can I set the y axis range of the second subplot to e.g. [0,1000] ?

The FFT plot of my data (a column in a text file) results in a (inf.?) spike so that the actual data is not visible.

pylab.ylim([0,1000])

has no effect, unfortunately. This is the whole script:

# based on http://www.swharden.com/blog/2009-01-21-signal-filtering-with-python/

import numpy, scipy, pylab, random

xs = []

rawsignal = []

with open("test.dat", 'r') as f:

for line in f:

if line[0] != '#' and len(line) > 0:

xs.append( int( line.split()[0] ) )

rawsignal.append( int( line.split()[1] ) )

h, w = 3, 1

pylab.figure(figsize=(12,9))

pylab.subplots_adjust(hspace=.7)

pylab.subplot(h,w,1)

pylab.title("Signal")

pylab.plot(xs,rawsignal)

pylab.subplot(h,w,2)

pylab.title("FFT")

fft = scipy.fft(rawsignal)

#~ pylab.axis([None,None,0,1000])

pylab.ylim([0,1000])

pylab.plot(abs(fft))

pylab.savefig("SIG.png",dpi=200)

pylab.show()

Other improvements are also appreciated!

解决方案pylab.ylim([0,1000])

Note: The command has to be executed after the plot!

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 扫一扫,分享海报

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2022 CSDN 皮肤主题:1024 设计师:我叫白小胖 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值