1

I cannot get pyplot to produce "cropped" images, that is, get rid of the grey left and right borders, as it is, it is not an accurate representation of the sound waveform : This sound file has no silence before and after.

enter image description here

My code :

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()
4

1 回答 1

3

OK, I got my answer :

f.subplots_adjust(0, 0, 1, 1)
于 2013-08-13T17:29:57.827 回答