Hi everyone. I am new to R. It will be greatly appreciated if someone can help me with the following questions. Here's the graph I have just produced. http://www.nabble.com/file/p24732839/calibration.jpeg (1) How can I put the legend on top of the grid lines? (2) How can I match the grid lines with the x-axis ticks? (3) How can I change the x-axis format from e.g. Mar, Apr...etc to 1-3-2009,1-4-2009...etc? Many thanks! :-) Chris -- View this message in context: http://www.nabble.com/Grid-lines-tp24732839p24732839.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
On Wed, 29-Jul-2009 at 11:32PM -0700, Chris Li wrote: |> |> Hi everyone. I am new to R. |> |> It will be greatly appreciated if someone can help me with the following |> questions. |> |> Here's the graph I have just produced. |> http://www.nabble.com/file/p24732839/calibration.jpeg |> |> (1) How can I put the legend on top of the grid lines? |> |> (2) How can I match the grid lines with the x-axis ticks? |> |> (3) How can I change the x-axis format from e.g. Mar, Apr...etc to |> 1-3-2009,1-4-2009...etc? You've obviously done some tinkering with the plot function, but I don't know which of the dozens of possible ways you used to do that, so I can't tell what adjustments are needed. There are some people on this list who are good at guessing, but it would make it easier for you if you told us. The operative phrase is 'reproducible code' and there's a few more of them in the footer of every message from this list. HTH -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) ..... Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
Chris Li wrote:> Hi everyone. I am new to R. > > It will be greatly appreciated if someone can help me with the following > questions. > > Here's the graph I have just produced. > http://www.nabble.com/file/p24732839/calibration.jpeg > > (1) How can I put the legend on top of the grid lines?It probably is on top. I guess you want white background as in: legend(....., bg="white")> (2) How can I match the grid lines with the x-axis ticks?grid() does exactly that for me, so I guess you are not using base graphics, hence please provide reproducible code as the posting guide suggests!> (3) How can I change the x-axis format from e.g. Mar, Apr...etc to > 1-3-2009,1-4-2009...etc?One way is to specify the x-axis separately, but since we do not know how you produced that plot .... Uwe Ligges> Many thanks! :-) > > Chris
Thanks for the reply guys. Below are the script and data files. http://www.nabble.com/file/p24734049/HEAD_calibration.R HEAD_calibration.R http://www.nabble.com/file/p24734049/6527-1052 6527-1052 http://www.nabble.com/file/p24734049/6527-1054 6527-1054 http://www.nabble.com/file/p24734049/MAR3 MAR3 Once again, thank you for your help, greatly appreciated!! Chris Chris Li wrote:> > Hi everyone. I am new to R. > > It will be greatly appreciated if someone can help me with the following > questions. > > Here's the graph I have just produced. > http://www.nabble.com/file/p24732839/calibration.jpeg > > (1) How can I put the legend on top of the grid lines? > > (2) How can I match the grid lines with the x-axis ticks? > > (3) How can I change the x-axis format from e.g. Mar, Apr...etc to > 1-3-2009,1-4-2009...etc? > > Many thanks! :-) > > Chris >-- View this message in context: http://www.nabble.com/Grid-lines-tp24732839p24734049.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
Maybe this helps par(mar = c(5,4,6,1)) plot(1:10, type = "n", axes = F) xticks = axis(1, at = c(1,5,9), labels = c("1-1-2009","1-5-2009","1-9-2009")) #set axis manually yticks = axis(2, at = 1:10) #set axis manually abline(v = xticks, col = "gray") #verticall lines abline(h = yticks, col = "gray", lty = 3) #horizontal lines legend(8,12, legend = c("test", "test"), col = 1:2, pch = 1:2, xpd = TRUE) points(1:10) Thomas Roth Chris Li schrieb:> Hi everyone. I am new to R. > > It will be greatly appreciated if someone can help me with the following > questions. > > Here's the graph I have just produced. > http://www.nabble.com/file/p24732839/calibration.jpeg > > (1) How can I put the legend on top of the grid lines? > > (2) How can I match the grid lines with the x-axis ticks? > > (3) How can I change the x-axis format from e.g. Mar, Apr...etc to > 1-3-2009,1-4-2009...etc? > > Many thanks! :-) > > Chris >
Maybe this helps par(mar = c(5,4,6,1)) plot(1:10, type = "n", axes = F) xticks = axis(1, at = c(1,5,9), labels c("1-1-2009","1-5-2009","1-9-2009")) #set axis manually yticks = axis(2, at = 1:10) #set axis manually abline(v = xticks, col = "gray") #verticall lines abline(h = yticks, col = "gray", lty = 3) #horizontal lines legend(8,12, legend = c("test", "test"), col = 1:2, pch = 1:2, xpd = TRUE) points(1:10) Thomas Roth Chris Li schrieb:> Hi everyone. I am new to R. > > It will be greatly appreciated if someone can help me with the following > questions. > > Here's the graph I have just produced. > http://www.nabble.com/file/p24732839/calibration.jpeg > > (1) How can I put the legend on top of the grid lines? > > (2) How can I match the grid lines with the x-axis ticks? > > (3) How can I change the x-axis format from e.g. Mar, Apr...etc to > 1-3-2009,1-4-2009...etc? > > Many thanks! :-) > > Chris >