In your plot call, you can use xaxt = "n" to turn off the default x
axis tick marks, then add
axis(1, at = VARIABLEWHEREYOUWANTTICKMARKS) # If you want ticks at
the x you put in, its just axis(1, at = x)
to get ticks where you want them. There's also a label= argument if
you want them to be labled as something other than the numbers.
Hope this helps,
Michael
On Thu, Oct 13, 2011 at 11:42 AM, lauren mcdonagh
<cleverlollipop at yahoo.ie> wrote:> Dear R users,
>
> I am quite desperate for help. I haven't used R in a couple of years
and I'm currently finishing a masters project and running out of time to
figure out my problem. I have read and tried the examples on many websites, in
your forums and R Help yet still can't manage to change the x axis. I am
using R 2.8.0 on windows.
>
> I'm sure there must be a way to do this as many people's questions
seem more difficult. My problem is that I need to change the numbers on the x
axis from the default.
>
> This is my scatter plot so far:
>
>
>> x <- c(0, 50, 100, 250, 500, 750, 1000, 1500, 2000, 2500, 3000)
>> y <- c(640, 585, 152, 85, 348, 922, 518, 82, 83, 591, 79)
>> plot(y~x, type = "p", xlab = "Distance (m)", ylab =
"Concentrations (mg/kg)", xlim = c(0,3000), ylim = c(0,1000), col
="black", pch = 19, sub = "Lead", font.sub = 2)
>> text(0,640, "mine average", pos = 4, col = "red",
cex= 0.6)
>> abline(h=c(21), lty = 2, col = "green", lwd =1)
>> abline(h=c(36), lty = 3, col = "blue", lwd = 1)
>> abline(h=c(190), lty = 1, col ="red", lwd = 2)
>> legend(1700, 1000, c("Control", "Dutch List -
Optimum", "Dutch List - Action"), col = c(3,4,2), lty = c(2,3,1),
cex = 0.8, lwd = c(1,1,2))
>
> R automatically changes the x axis to 0, 500, 100, 1500, 2000, 2500, 3000.
I've tried a few things you've already said to other people with
problems but all I get is error.
>
> I would really appreciate some help as I've no one else to ask (the uni
I've studied my masters in does not use R).
>
> Yours faithfully,
>
> Lauren.
> ? ? ? ?[[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>