prompt function to customize axis labels - cosmetic question
chemgoof
Code for graph is as follows...
<br />
Macro Makediurnal(JDayStr,wave2avgStr,waveAvgStr)<br />
String JDayStr, wave2avgStr, waveAvgStr="my_avg"<br />
prompt JDayStr, "JDay of the data for the diurnal?",popup SortList(WaveList("*",";",""), ";", 16)<br />
prompt wave2avgStr, "Data for the diurnal?",popup SortList(WaveList("*",";",""), ";", 16)<br />
prompt waveAvgStr, "Name to give the diurnal wave?"<br />
<br />
if (numpnts($JDayStr)!=numpnts($wave2avgStr))<br />
Abort " The first two waves must have the same number of points."+JDayStr + " "+wave2avgStr+ " - Aborting from Macro"<br />
endif <br />
<br />
if (strlen(waveAvgStr)==0) <br />
Abort "You need to insert values into the name prompts - Aborting from Macro"<br />
endif<br />
<br />
waveAvgStr = CleanUpName(waveAvgStr, 0)<br />
Make/o/n=24 $waveAvgStr<br />
<br />
DoMakediurnal($JDayStr, $wave2avgStr, $waveAvgStr)<br />
<br />
Rename sdev $waveAvgStr + "_sdev"<br />
Display $waveAvgStr vs Hours<br />
ModifyGraph mode=4,marker=16<br />
Label left "Diurnal of " + NameofWave($wave2avgStr) + """insert units here???"""<br />
Label bottom "Hour of Day"<br />
ErrorBars $waveAvgStr Y,wave=($waveAvgStr + "_sdev",$waveAvgStr + "_sdev")<br />
<br />
End<br />
<br />
Function DoMakediurnal(JDay, wave2avg, waveAvg)<br />
Wave JDay, wave2avg, waveAvg<br />
<br />
Make/D/N=24 Hours=0<br />
Hours=Hours[p-1]+1<br />
<br />
Make/D/N=24 Day_Frac=Hours/24<br />
<br />
Duplicate JDay JDay_Frac<br />
JDay_Frac=JDay-floor(JDay)<br />
<br />
Wave Hours,Day_Frac,JDay_frac<br />
<br />
waveAvg=mean_bin(Jday_Frac,wave2avg,Day_Frac)<br />
End<br />
Macro Makediurnal(JDayStr,wave2avgStr,waveAvgStr)<br />
String JDayStr, wave2avgStr, waveAvgStr="my_avg"<br />
prompt JDayStr, "JDay of the data for the diurnal?",popup SortList(WaveList("*",";",""), ";", 16)<br />
prompt wave2avgStr, "Data for the diurnal?",popup SortList(WaveList("*",";",""), ";", 16)<br />
prompt waveAvgStr, "Name to give the diurnal wave?"<br />
<br />
if (numpnts($JDayStr)!=numpnts($wave2avgStr))<br />
Abort " The first two waves must have the same number of points."+JDayStr + " "+wave2avgStr+ " - Aborting from Macro"<br />
endif <br />
<br />
if (strlen(waveAvgStr)==0) <br />
Abort "You need to insert values into the name prompts - Aborting from Macro"<br />
endif<br />
<br />
waveAvgStr = CleanUpName(waveAvgStr, 0)<br />
Make/o/n=24 $waveAvgStr<br />
<br />
DoMakediurnal($JDayStr, $wave2avgStr, $waveAvgStr)<br />
<br />
Rename sdev $waveAvgStr + "_sdev"<br />
Display $waveAvgStr vs Hours<br />
ModifyGraph mode=4,marker=16<br />
Label left "Diurnal of " + NameofWave($wave2avgStr) + """insert units here???"""<br />
Label bottom "Hour of Day"<br />
ErrorBars $waveAvgStr Y,wave=($waveAvgStr + "_sdev",$waveAvgStr + "_sdev")<br />
<br />
End<br />
<br />
Function DoMakediurnal(JDay, wave2avg, waveAvg)<br />
Wave JDay, wave2avg, waveAvg<br />
<br />
Make/D/N=24 Hours=0<br />
Hours=Hours[p-1]+1<br />
<br />
Make/D/N=24 Day_Frac=Hours/24<br />
<br />
Duplicate JDay JDay_Frac<br />
JDay_Frac=JDay-floor(JDay)<br />
<br />
Wave Hours,Day_Frac,JDay_frac<br />
<br />
waveAvg=mean_bin(Jday_Frac,wave2avg,Day_Frac)<br />
End<br />
mean_bin is an averaging function that returns waveAvg and sdev. What I want is to make a "units" string(?, or maybe label?) defined by the user that will insert into the label.
DoPrompt
to ask for the label, set the units usingSetScale
to the wave itself and then use \U in the label to refer to the unit.Example:
string unitx = "m", unity = "s"
Prompt unitx, "X unit"
Prompt unity, "Y unit"
DoPrompt "Please enter the units", unitx, unity
Make/O data = enoise(p)
SetScale/P x, DimOffset(data,0), DimDelta(data,0), unitx, data
SetScale d, 0,0, unity, data
Display data
Label left "Some y data [\U]"
Label bottom "Some x data [\U]"
End
February 6, 2014 at 12:24 pm - Permalink
February 12, 2014 at 03:58 pm - Permalink