Hurr
2014-May-13 21:52 UTC
[R] Put short string labels vertically near tick marks on bottom axis
A month ago I was considering the forum topic ?Label axis tick marks with a simple function of axis value? and haven?t had time to work much on it. Since then I have written a little program that makes period labels for the frequency axis, but I don?t know how to attach them. I expected the following code to work. Later there will be more requirements like 1) labels should be vertical 2) the bottom of the labels should line up with the ticks 3) requirements beyond today?s consideration horAxisLims=c(0,7200) verData=c(1,365,809,1252,1753,2191,2922,3409,3896,4383,4819,5255,5691,6128,6564,7000) horData=c(1,300,800,1200,1700,2100,2900,3400,3800,4300,4800,5200,5600,6100,6500,7000) #not at tics horTicLocs=c(1,365,809,1252,1753,2191,2922,3409,3896,4383,4819,5255,5691,6128,6564,7000) horLabels=c(?1Yr?,?1Da?,?10.8Hr?,?7Hr?,?5Hr?,?4Hr?,?3Hr?,?2.57Hr?,?2.25Hr?,?2Hr?,?1.82Hr?,?1.67Hr?,?1.54Hr?,?1.43Hr?,?1.34Hr?,?1.25Hr?) plot(horData, verData,xaxt='n',xlim= horAxisLims) axis(1,tick=TRUE,at= horTicLocs, labels= horLabels) -- View this message in context: http://r.789695.n4.nabble.com/Put-short-string-labels-vertically-near-tick-marks-on-bottom-axis-tp4690452.html Sent from the R help mailing list archive at Nabble.com.
Jim Lemon
2014-May-13 22:17 UTC
[R] Put short string labels vertically near tick marks on bottom axis
On Tue, 13 May 2014 02:52:09 PM Hurr wrote:> A month ago I was considering the forum topic > ?Label axis tick marks with a simple function of axis value? > and haven?t had time to work much on it. > Since then I have written a little program that makes > period labels for the frequency axis, but I don?t know how to attachthem.> I expected the following code to work. > Later there will be more requirements like > 1) labels should be vertical > 2) the bottom of the labels should line up with the ticks > 3) requirements beyond today?s consideration > > horAxisLims=c(0,7200) >verData=c(1,365,809,1252,1753,2191,2922,3409,3896,4383,4819,5255,5691,6128,6> 564,7000) >horData=c(1,300,800,1200,1700,2100,2900,3400,3800,4300,4800,5200,5600,6100,> 6500,7000) #not at tics >horTicLocs=c(1,365,809,1252,1753,2191,2922,3409,3896,4383,4819,5255,5691,612> 8,6564,7000) >horLabels=c(?1Yr?,?1Da?,?10.8Hr?,?7Hr?,?5Hr?,?4Hr?,?3Hr?,?2.57Hr?,?2.25Hr?,> ?2Hr?,?1.82Hr?,?1.67Hr?,?1.54Hr?,?1.43Hr?,?1.34Hr?,?1.25Hr?)plot(horData,> verData,xaxt='n',xlim= horAxisLims) > axis(1,tick=TRUE,at= horTicLocs, labels= horLabels) >Hi Hurr, This might solve questions 1 and 2 for you: axis(1,tick=TRUE,at= horTicLocs,labels=rep("",length(horLabels))) library(plotrix) staxlab(1,at=horTicLocs,labels=horLabels,srt=90,adj=c(1,0)) As for question 3, I'll have to pass as I make no claims to prophecy. Jim
David Winsemius
2014-May-13 22:22 UTC
[R] Put short string labels vertically near tick marks on bottom axis
On May 13, 2014, at 2:52 PM, Hurr wrote:> A month ago I was considering the forum topic > ?Label axis tick marks with a simple function of axis value? > and haven?t had time to work much on it. > Since then I have written a little program that makes > period labels for the frequency axis, but I don?t know how to attach them. > I expected the following code to work. > Later there will be more requirements like > 1) labels should be vertical > 2) the bottom of the labels should line up with the ticks > 3) requirements beyond today?s consideration > > horAxisLims=c(0,7200) > verData=c(1,365,809,1252,1753,2191,2922,3409,3896,4383,4819,5255,5691,6128,6564,7000) > horData=c(1,300,800,1200,1700,2100,2900,3400,3800,4300,4800,5200,5600,6100,6500,7000) > #not at tics > horTicLocs=c(1,365,809,1252,1753,2191,2922,3409,3896,4383,4819,5255,5691,6128,6564,7000) > horLabels=c(?1Yr?,?1Da?,?10.8Hr?,?7Hr?,?5Hr?,?4Hr?,?3Hr?,?2.57Hr?,?2.25Hr?,?2Hr?,?1.82Hr?,?1.67Hr?,?1.54Hr?,?1.43Hr?,?1.34Hr?,?1.25Hr?) > plot(horData, verData,xaxt='n',xlim= horAxisLims) > axis(1,tick=TRUE,at= horTicLocs, labels= horLabels) >Yecchh. Pasted code throws an error in the horLabels assignment. "Smart quotes". Use a proper text editor. -- David Winsemius Alameda, CA, USA