
Auto scale left axis based on currently displayed waves

AlonPolegPolsky
Function AutoscaleLeft() if((stringmatch(AxisList(""),"*bottom*")==0)||(stringmatch(AxisList(""),"*left*")==0)) print "no left or bottom axis" else getaxis/q bottom variable num=0,minB=V_min,maxB=V_max,minL=inf,maxL=-inf do if (waveexists(WaveRefIndexed("",num,1))) Duplicate/o WaveRefIndexed("",num,1), temp if(wavemax(temp,minB,maxB)>maxL) maxL=wavemax(temp,minB,maxB) endif if(wavemin(temp,minB,maxB)<minL) minL=wavemin(temp,minB,maxB) endif else break endif num+=1 while(1) setaxis left, minL,maxL killwaves/z temp endif End Menu "Graph" "Autoscale Left Axis",/q ,AutoscaleLeft() End Menu "TracePopup" "Autoscale Left Axis",/q ,AutoscaleLeft() End

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
You're code is essentially re-implementing:
except that your code "locks" the left axis range to the current Y min/max over the current X range and assumes that all the traces are waveforms (you're using x scaling to select "visible" Y values).
That said, this implementation is a bit faster:
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
February 13, 2015 at 11:58 am - Permalink