Note that there are some explanatory texts on larger screens.

plurals
  1. POChange the number of tick marks on a figure in R
    primarykey
    data
    text
    <p>I created a figure of two plots (two years) of climate data (temp and precip) that looks exactly like I want it, except that one of my axes has too many tick marks. With everything I have going on with this figure, I can't find a way to specify fewer tick marks without messing up other parts. I would also like to specify where the tick marks are. Here is the figure: <img src="https://i.imgur.com/XyVeWlh.png" alt="Climate"></p> <p>You can see that the tick marks for the top axis just blur together and the numbers chosen are not very meaningful to me. How can I tell R what I really want?</p> <p>Here are the datasets I am using: <a href="https://www.dropbox.com/s/ysoiut7ma5y8q30/cobs10.txt" rel="nofollow noreferrer">cobs10</a> and <a href="https://www.dropbox.com/sh/phonq4ssjv5dnb0/7iLelar0pR" rel="nofollow noreferrer">cobs11</a>.</p> <p>And here is my code:</p> <pre><code>par(mfrow=c(2,1)) par(mar = c(5,4,4,4) + 0.3) plot(cobs10$day, cobs10$temp, type="l", col="red", yaxt="n", xlab="", ylab="", ylim=c(-25, 30)) axis(side=3, col="black", at=cobs10$day, labels=cobs10$gdd) at = axTicks(3) mtext("Thermal Units", side=3, las=0, line = 3) axis(side=2, col='red', labels=FALSE) at= axTicks(2) mtext(side=2, text= at, at = at, col = "red", line = 1, las=0) mtext("Temperature (C)", side=2, las=0, line=3) par(new=TRUE) plot(cobs10$gdd, cobs10$precip, type="h", col="blue", yaxt="n", xaxt="n", ylab="", xlab="") axis(side=4, col='blue', labels=FALSE) at = axTicks(4) mtext(side = 4, text = at, at = at, col = "blue", line = 1,las=0) mtext("Precipitation (cm)", side=4, las=0, line = 3) par(mar = c(5,4,4,4) + 0.3) plot(cobs11$day, cobs11$temp, type="l", col="red", yaxt="n", xlab="Day of Year", ylab="", ylim=c(-25, 30)) axis(side=3, col="black", at=cobs11$day, labels=cobs11$gdd) at = axTicks(3) mtext("", side=3, las=0, line = 3) axis(side=2, col='red', labels=FALSE) at= axTicks(2) mtext(side=2, text= at, at = at, col = "red", line = 1, las=0) mtext("Temperature (C)", side=2, las=0, line=3) par(new=TRUE) plot(cobs11$gdd, cobs11$precip, type="h", col="blue", yaxt="n", xaxt="n", ylab="", xlab="", ylim=c(0,12)) axis(side=4, col='blue', labels=FALSE) at = axTicks(4) mtext(side = 4, text = at, at = at, col = "blue", line = 1,las=0) mtext("Precipitation (cm)", side=4, las=0, line = 3) </code></pre> <p>Thanks for thinking about it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload