Changeset e8dd49f


Ignore:
Timestamp:
Feb 8, 2013, 5:30:51 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
21e2d5e3
Parents:
7175ed4
Message:

demo_spectrogram.py: improve ticks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/demo_spectrogram.py

    r7175ed4 re8dd49f  
    2525  imshow(log10(specgram.T + .001), origin = 'bottom', aspect = 'auto', cmap=cm.gray_r)
    2626  axis([0, len(specgram), 0, len(specgram[0])])
    27   ylabel('Frequency (Hz)')
    28   xlabel('Time (s)')
    2927  # show axes in Hz and seconds
    3028  time_step = hop_s / float(samplerate)
    3129  total_time = len(specgram) * time_step
    32   ticks = 10
    33   xticks( arange(ticks) / float(ticks) * len(specgram),
    34       [x * total_time / float(ticks) for x in range(ticks) ] )
    35   yticks( arange(ticks) / float(ticks) * len(specgram[0]),
    36       [x * samplerate / 2. / float(ticks) for x in range(ticks) ] )
     30  print "total time: %0.2fs" % total_time,
     31  print ", samplerate: %.2fkHz" % (samplerate / 1000.)
     32  n_xticks = 10
     33  n_yticks = 10
     34  xticks_pos = [          x / float(n_xticks) * len(specgram) for x in range(n_xticks) ]
     35  xticks_str = [  "%.2f" % (x * total_time / float(n_xticks)) for x in range(n_xticks) ]
     36  xticks( xticks_pos , xticks_str )
     37  yticks_pos = [           y / float(n_yticks) * len(specgram[0]) for y in range(n_yticks) ]
     38  yticks_str = [ "%.2f" % (y * samplerate / 2000. / float(n_yticks)) for y in range(n_yticks) ]
     39  yticks( yticks_pos , yticks_str )
     40  ylabel('Frequency (kHz)')
     41  xlabel('Time (s)')
    3742
    3843if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.