USGS-R / smwrGraphs

Moved to: https://code.usgs.gov/water/analysis-tools/smwrGraphs
https://code.usgs.gov/water/analysis-tools/smwrGraphs
Other
18 stars 16 forks source link

How to suppress right side tick marks? #33

Closed ldecicco-USGS closed 5 years ago

ldecicco-USGS commented 8 years ago

From an email:

I'm plotting some data on the right axis of a time series plot, but the first plot from the left axis has tick marks on the right axis, and there is overlap. I've been trying to use renderPretty, but not sure where it would go in the code below (not complete code, btw). Any ideas?

setSweave("MillerCrk_Q_TP",11,8.5)
AA.lo <- setLayout(num.rows=3,num.cols=1,num.graphs=3, xtop=3.5,yright=3.5)
AA.gr <- setGraph(1, AA.lo)
MillerCrkWQ.yr1.pl <- with(BOR_Q_yr1,timePlot(Date, MillerCrk_dailyQ_cfs, 
                                              Plot=list(name="Malone Daily Q-BOR", what="lines", color="blue"),
                                              yaxis.log=FALSE, yaxis.range=c(-50,500),ytitle="Daily Streamflow(cfs)", 
                                             caption="Year 1", margin=AA.gr, right=list(ticks=FALSE)))

#MillerCrkWQ.yr1.pl <- renderY(pretty,right=list(ticks=FALSE))

MillerCrkWQ.yr1.pl <- with(USGS_WQ_yr1,addXY(DATETIME, TP, 
                                             Plot=list(name="Total P (mg/L)",what="points", symbol="diamond",
                                             color="red", filled=TRUE,size=0.05),
                                              current=MillerCrkWQ.yr1.pl, new.axis="right",new.log=FALSE, new.title="Total P in mg/L"))

addTitle("Miller Creek below Round Valley", Justification="center", Bold=TRUE, Position='above')
addExplanation(MillerCrkWQ.yr1.pl, "ur")
jordansread commented 8 years ago

Your margin argument to timePlot can include a negative value to any axis side that you wish to suppress the ticks for. So in your code,

AA.gr = setGraph(2, AA.lo)

returns the following vector for the axes:

AA.gr
[1]   NA   NA  3.5 3.5

NA for bottom (I think this means “auto”), NA for left, 3.5 for the top, and 3.5 for the bottom. If you use a negative numbers instead of 3.5, it will suppress the ticks on that side. So

MillerCrkWQ.yr1.pl <- with(BOR_Q_yr1,timePlot(Date, MillerCrk_dailyQ_cfs, 
                                              Plot=list(name="Malone Daily Q-BOR", what="lines", color="blue"),
                                              yaxis.log=FALSE, yaxis.range=c(-50,500),ytitle="Daily Streamflow(cfs)", 
                                             caption="Year 1", margin=c(NA,NA,3.5,-3.5), right=list(ticks=FALSE)))

works, or you can use the “noTicks” argument to “setGraph”:

AA.gr = setGraph(2, AA.lo, noTicks=c(4))