gpt4 book ai didi

Python Matplotlib : Just the graph image

转载 作者:行者123 更新时间:2023-11-30 23:34:19 25 4
gpt4 key购买 nike

我无法获取pyplot产生“裁剪”图像,即去掉灰色的左右边框,事实上,它并不是声音波形的准确表示:该声音文件前后没有静音。

enter image description here

我的代码:

import gtk

from matplotlib.figure import Figure
from numpy import arange, sin, pi
import scipy.io.wavfile as wavfile

from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas

win = gtk.Window()
win.connect("destroy", lambda x: gtk.main_quit())
win.set_default_size(400,300)
win.set_title("Cropping figure")

rate, data = wavfile.read(open('/home/px/gare_du_nord-catchlak.wav', 'r'))
f = Figure()
a = f.add_subplot(111, axisbg=(0.1843, 0.3098, 0.3098))
a.plot(range(len(data)),data, color="OrangeRed", linewidth=0.5, linestyle="-")
a.axis('off')
a.autoscale_view('tight')
canvas = FigureCanvas(f) # a gtk.DrawingArea

win.add(canvas)

win.show_all()
gtk.main()

最佳答案

好的,我得到了my answer :

f.subplots_adjust(0, 0, 1, 1)

编辑:

这也有效,事实上它甚至更好:

a.margins(0, 0)

关于Python Matplotlib : Just the graph image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18215340/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com