From graphics-request at octave dot org Thu Aug 5 18:43:16 2004 Subject: Re: freqz_plot alterations From: Paul Kienzle To: Daniel J Sebald Cc: octave-graphics Date: Thu, 5 Aug 2004 19:42:55 -0400 Daniel, The unified diffs help. In general it is better not to have gnuplot primitives in high level plots. Instead we should be working to make the low-level plot primitives in octave. I realize I already break that rule by having gset margin commands. It would be nice to eliminate those as well. Octave-forge has the 'tics' function which you could extend so that it expands to gset ytics n when given scalar n, rather than the current behaviour of gset ytics (n) This function needs its docs converted to texinfo format before it can be included in octave. As for origin, please extend the subplot command to accept subplot('Position',[left bottom width height]) where left, bottom, width and height are in [0,1] relative to entire figure. Don't forget to add this to the docs. Thanks, - Paul On Aug 5, 2004, at 2:35 PM, Daniel J Sebald wrote: > Daniel J Sebald wrote: > > For anyone interested, attached are some slight alterations > > to the freqz_plot.m file. The three plots are made to have the > > same height and the tics for the phase angle are made more > > congruous with 5, 15, 30, 45, 60, etc (Being able to specify a > > sample rate, i.e., non-normalized frequency would be nice, > > but probably not compatible.) > > Sorry, I forgot the unified flag. A new diff file is attached. > > Also, I've noticed a roundoff problem with the right border using > gnuplot. Sometimes the right border is slightly to the left of the > vertical grid line and tic. The issue is that > > axis ([ w(1), w(n), maxmag-3, maxmag ]); > > translates to > > gset xrange [0:1.99805] > > (i.e., w(n) = 1.99805) which causes the aberration, whereas > > gset xrange [0:2] > > avoids the aberration. I've posted to the gnuplot beta list wondering > if this is gnuplot's problem or not. (My opinion is that it is.) > > Dan > > --- > /usr/src/redhat/SOURCES/octave-2.1.57/scripts/signal/freqz_plot.m Mon > Nov 24 21:59:41 2003 > +++ freqz_plot-2.1.57-mod.m Thu Aug 5 13:15:48 2004 > at @ -1,3 +1,14 @@ > +## EXPERIMENTAL CODE!!! by Dan Sebald. (Aug 5, 2004) > +## > +## This file is NOT part of the Octave distribution. > +## > +## This file is a variation of the freqz_plot.m file from version > +## 2.1.57. The plot locations are changed so that all plot heights > +## are the same. Also, the phase plot attempts to choose a more > +## appropriate tic for angles. > +## > +## > ===================================================================== > +## > ## Copyright (C) 2002 John W. Eaton > ## > ## This file is part of Octave. > at @ -45,6 +56,10 @@ > automatic_replot = 0; > > subplot (311); > + gset size 1,0.26; > + gset origin 0,0.72; > + gset bmargin 0; > + gset tmargin 0; > gset lmargin 10; > axis ("labely"); > xlabel (""); > at @ -52,11 +67,10 @@ > axis ([ w(1), w(n), maxmag-3, maxmag ]); > plot (w, mag, ";Pass band (dB);"); > > - subplot (312); > + gset origin 0,0.42; > axis ("labely"); > title (""); > xlabel (""); > - gset tmargin 0; > grid ("on"); > if (maxmag - min (mag) > 100) > axis ([ w(1), w(n), maxmag-100, maxmag ]); > at @ -65,10 +79,28 @@ > endif > plot (w, mag, ";Stop band (dB);"); > > - subplot (313); > + gset origin 0,0.12; > axis ("label"); > title (""); > grid ("on"); > + phasediff = (max (phase) - min (phase))*360/(2*pi); > + if (phasediff < 5) > + gset ytics autofreq; > + elseif (phasediff < 30) > + gset ytics 5; > + elseif (phasediff < 90) > + gset ytics 15; > + elseif (phasediff < 180) > + gset ytics 30; > + elseif (phasediff < 240) > + gset ytics 45; > + elseif (phasediff < 360) > + gset ytics 60; > + elseif (phasediff < 540) > + gset ytics 90; > + else > + gset ytics autofreq; > + endif > axis ("autoy"); > xlabel ("Frequency"); > axis ([ w(1), w(n) ]); > at @ -86,6 +118,8 @@ > axis ("auto", "label"); > gset lmargin; > gset tmargin; > + gset bmargin; > + gset ytics autofreq; > oneplot (); > > automatic_replot = replot_state;