Hi, A few times I tried to control the number and position of tick marks in plots with the yasp or xasp parameters. For example, a y axis was drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to get tick marks every 10 by adding yasp=(0, 100, 10) but this had no effect at all. I know I can draw the axis and tick marks manually, but often this simple option would suffice if I could understand how to make it work. Thanks in advance, Denis Chabot
how to control ticks in plots with yasp or xasp
9 messages · Marc Schwartz, Brian Ripley, Peter Dalgaard +1 more
On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
Hi, A few times I tried to control the number and position of tick marks in plots with the yasp or xasp parameters. For example, a y axis was drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to get tick marks every 10 by adding yasp=(0, 100, 10) but this had no effect at all. I know I can draw the axis and tick marks manually, but often this simple option would suffice if I could understand how to make it work. Thanks in advance, Denis Chabot
I suspect that one problem you are having is that there is no
par("xasp") or par("yasp")....unless these are typos and you are trying
to use par("xaxp") and par("yaxp")?
There is an 'asp' argument to some of the plot functions (ie.
plot.default), but this has a different intention.
par("xaxp") and par("yaxp") are not listed as read only pars in ?par,
however, I cannot recall an instance where R does not overwrite the user
settings during the calculation of the axes, whether passed as arguments
to a plot function or set a priori via a par() call.
If you want explicit control over the tick marks, you will need to use
axis(), perhaps in combination with axTicks(), after using 'xaxt = "n"'
and/or 'yaxt = "n"' in the plot call, depending upon the circumstances.
HTH,
Marc Schwartz
Oops, Mark, bad typo indeed. But yaxp is what I had in my R program and it did not help. I did obtain control over my tick marks by drawing them myself, as you suggest. But I was curious as to how to use yaxp since the help on "par" gives it as a possible way of controlling ticks. Maybe it should be removed from the help file? Thanks for your help, Denis Le 05-10-08 ?? 11:16, Marc Schwartz a ??crit :
On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
Hi, A few times I tried to control the number and position of tick marks in plots with the yasp or xasp parameters. For example, a y axis was drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to get tick marks every 10 by adding yasp=(0, 100, 10) but this had no effect at all. I know I can draw the axis and tick marks manually, but often this simple option would suffice if I could understand how to make it work. Thanks in advance, Denis Chabot
I suspect that one problem you are having is that there is no
par("xasp") or par("yasp")....unless these are typos and you are
trying
to use par("xaxp") and par("yaxp")?
There is an 'asp' argument to some of the plot functions (ie.
plot.default), but this has a different intention.
par("xaxp") and par("yaxp") are not listed as read only pars in ?par,
however, I cannot recall an instance where R does not overwrite the
user
settings during the calculation of the axes, whether passed as
arguments
to a plot function or set a priori via a par() call.
If you want explicit control over the tick marks, you will need to use
axis(), perhaps in combination with axTicks(), after using 'xaxt =
"n"'
and/or 'yaxt = "n"' in the plot call, depending upon the
circumstances.
HTH,
Marc Schwartz
On Sat, 8 Oct 2005, Marc Schwartz wrote:
On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
Hi, A few times I tried to control the number and position of tick marks in plots with the yasp or xasp parameters. For example, a y axis was drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to get tick marks every 10 by adding yasp=(0, 100, 10) but this had no effect at all. I know I can draw the axis and tick marks manually, but often this simple option would suffice if I could understand how to make it work. Thanks in advance, Denis Chabot
I suspect that one problem you are having is that there is no
par("xasp") or par("yasp")....unless these are typos and you are trying
to use par("xaxp") and par("yaxp")?
In any case, (0, 100, 10) is invalid syntax, and c(0, 100, 10) is needed.
There is an 'asp' argument to some of the plot functions (ie.
plot.default), but this has a different intention.
par("xaxp") and par("yaxp") are not listed as read only pars in ?par,
however, I cannot recall an instance where R does not overwrite the user
settings during the calculation of the axes, whether passed as arguments
to a plot function or set a priori via a par() call.
Really? Try
plot(1:100, xaxt="n") par(xaxp=c(0, 50, 5)) # the value is reset at each plot axis(1)
for how it works (but not inline, which is probably a bug).
If you want explicit control over the tick marks, you will need to use axis(), perhaps in combination with axTicks(), after using 'xaxt = "n"' and/or 'yaxt = "n"' in the plot call, depending upon the circumstances.
That is usually as easy.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Denis Chabot <chabotd at globetrotter.net> writes:
Oops, Mark, bad typo indeed. But yaxp is what I had in my R program and it did not help. I did obtain control over my tick marks by drawing them myself, as you suggest. But I was curious as to how to use yaxp since the help on "par" gives it as a possible way of controlling ticks. Maybe it should be removed from the help file?
plot(1)
par("xaxp")
par(xaxp=c(.6,1.4,8))
axis(3)
So it does do something...
Thanks for your help, Denis Le 05-10-08 ?? 11:16, Marc Schwartz a ??crit :
On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
Hi, A few times I tried to control the number and position of tick marks in plots with the yasp or xasp parameters. For example, a y axis was drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to get tick marks every 10 by adding yasp=(0, 100, 10) but this had no effect at all. I know I can draw the axis and tick marks manually, but often this simple option would suffice if I could understand how to make it work. Thanks in advance, Denis Chabot
I suspect that one problem you are having is that there is no
par("xasp") or par("yasp")....unless these are typos and you are
trying
to use par("xaxp") and par("yaxp")?
There is an 'asp' argument to some of the plot functions (ie.
plot.default), but this has a different intention.
par("xaxp") and par("yaxp") are not listed as read only pars in ?par,
however, I cannot recall an instance where R does not overwrite the
user
settings during the calculation of the axes, whether passed as
arguments
to a plot function or set a priori via a par() call.
If you want explicit control over the tick marks, you will need to use
axis(), perhaps in combination with axTicks(), after using 'xaxt =
"n"'
and/or 'yaxt = "n"' in the plot call, depending upon the
circumstances.
HTH,
Marc Schwartz
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
On Sat, 2005-10-08 at 16:37 +0100, Prof Brian Ripley wrote:
On Sat, 8 Oct 2005, Marc Schwartz wrote:
On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
Hi, A few times I tried to control the number and position of tick marks in plots with the yasp or xasp parameters. For example, a y axis was drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to get tick marks every 10 by adding yasp=(0, 100, 10) but this had no effect at all. I know I can draw the axis and tick marks manually, but often this simple option would suffice if I could understand how to make it work. Thanks in advance, Denis Chabot
I suspect that one problem you are having is that there is no
par("xasp") or par("yasp")....unless these are typos and you are trying
to use par("xaxp") and par("yaxp")?
In any case, (0, 100, 10) is invalid syntax, and c(0, 100, 10) is needed.
Indeed.
There is an 'asp' argument to some of the plot functions (ie.
plot.default), but this has a different intention.
par("xaxp") and par("yaxp") are not listed as read only pars in ?par,
however, I cannot recall an instance where R does not overwrite the user
settings during the calculation of the axes, whether passed as arguments
to a plot function or set a priori via a par() call.
Really? Try
plot(1:100, xaxt="n") par(xaxp=c(0, 50, 5)) # the value is reset at each plot axis(1)
for how it works (but not inline, which is probably a bug).
Ah....I had not thought about that 'par'ticular combination... ;-) Hence, not R.O. So it must be used _after_ a plot call, which makes sense. I had reached for my copy of Paul's book and on page 96 (last paragraph in section 3.4.5 on Axes), he suggests using the approach I elucidate below with axTicks(). I thought he might have some other ideas and that I was missing something. This is also referenced on page 70, third paragraph in section 3.2.5 on Axes.
If you want explicit control over the tick marks, you will need to use axis(), perhaps in combination with axTicks(), after using 'xaxt = "n"' and/or 'yaxt = "n"' in the plot call, depending upon the circumstances.
That is usually as easy.
Agreed. Thanks, Marc
Hi, sorry about the bad syntax, though the right syntax would not have worked either, according to your tests (Mark, Brian, Peter). Anyway it is too finicky, I will draw them myself. For instance, plot(1:100, xaxt="n") par(xaxp=c(0, 100, 10)) # the value is reset at each plot axis(1) Placed tick marks at intervals at 0, 10, ..., 100, as expected, but did not place a label under 100... Thanks for the answers, usufull as always, Denis Le 05-10-08 ?? 11:58, Marc Schwartz a ??crit :
On Sat, 2005-10-08 at 16:37 +0100, Prof Brian Ripley wrote:
On Sat, 8 Oct 2005, Marc Schwartz wrote:
On Sat, 2005-10-08 at 09:28 -0400, Denis Chabot wrote:
Hi, A few times I tried to control the number and position of tick marks in plots with the yasp or xasp parameters. For example, a y axis was drawn by default with tick marks at 0, 20, 40, 80 and 100. I tried to get tick marks every 10 by adding yasp=(0, 100, 10) but this had no effect at all. I know I can draw the axis and tick marks manually, but often this simple option would suffice if I could understand how to make it work. Thanks in advance, Denis Chabot
I suspect that one problem you are having is that there is no
par("xasp") or par("yasp")....unless these are typos and you are
trying
to use par("xaxp") and par("yaxp")?
In any case, (0, 100, 10) is invalid syntax, and c(0, 100, 10) is needed.
Indeed.
There is an 'asp' argument to some of the plot functions (ie.
plot.default), but this has a different intention.
par("xaxp") and par("yaxp") are not listed as read only pars in ?
par,
however, I cannot recall an instance where R does not overwrite
the user
settings during the calculation of the axes, whether passed as
arguments
to a plot function or set a priori via a par() call.
Really? Try
plot(1:100, xaxt="n") par(xaxp=c(0, 50, 5)) # the value is reset at each plot axis(1)
for how it works (but not inline, which is probably a bug).
Ah....I had not thought about that 'par'ticular combination... ;-) Hence, not R.O. So it must be used _after_ a plot call, which makes sense. I had reached for my copy of Paul's book and on page 96 (last paragraph in section 3.4.5 on Axes), he suggests using the approach I elucidate below with axTicks(). I thought he might have some other ideas and that I was missing something. This is also referenced on page 70, third paragraph in section 3.2.5 on Axes.
If you want explicit control over the tick marks, you will need to use axis(), perhaps in combination with axTicks(), after using 'xaxt = "n"' and/or 'yaxt = "n"' in the plot call, depending upon the circumstances.
That is usually as easy.
Agreed. Thanks, Marc
On Sat, 8 Oct 2005, Denis Chabot wrote:
Hi, sorry about the bad syntax, though the right syntax would not have worked either, according to your tests (Mark, Brian, Peter).
It DOES work according to my tests! (Do give us the credit for testing our advice: we would appreciate your showing equal care.)
Anyway it is too finicky, I will draw them myself. For instance, plot(1:100, xaxt="n") par(xaxp=c(0, 100, 10)) # the value is reset at each plot axis(1) Placed tick marks at intervals at 0, 10, ..., 100, as expected, but did not place a label under 100...
Does for me (2.2.0, Windows and X11 on Linux). Might the text be clipped on your unnamed device, so you need to set xpd? (If so, it will be clipped however you try to do this, and is an unrelated local problem.)
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hi Brian, Le 05-10-08 ?? 13:21, Prof Brian Ripley a ??crit :
On Sat, 8 Oct 2005, Denis Chabot wrote:
Hi, sorry about the bad syntax, though the right syntax would not have worked either, according to your tests (Mark, Brian, Peter).
It DOES work according to my tests! (Do give us the credit for testing our advice: we would appreciate your showing equal care.)
I am very sorry, I did not express myself properly. I do appreciate your help, and I did take the time to test your solution. What I meant was that even if I had use the proper syntax, i.e. yaxp=c (10,100,10) instead of y=(10,100,10) [actually in my program I had used it but I was careless when I composed the message], it would not have worked because you demonstrated that it has to be used within a "par" statement, which I had not done. Therefore my attempt was doomed. I did not mean there was no way to make yaxp work, so I apologize if you think I take your advice lightly, and I cannot state strongly enough that it is not the case at all.
Anyway it is too finicky, I will draw them myself. For instance, plot(1:100, xaxt="n") par(xaxp=c(0, 100, 10)) # the value is reset at each plot axis(1) Placed tick marks at intervals at 0, 10, ..., 100, as expected, but did not place a label under 100...
Does for me (2.2.0, Windows and X11 on Linux). Might the text be clipped on your unnamed device, so you need to set xpd? (If so, it will be clipped however you try to do this, and is an unrelated local problem.)
This is strange. I work on Mac OS X, so the default device is quartz. Label 100 is shown without clipping if plot without changing xaxp. But just in case I made more space at the right of the graph with par(mai=c(0.7, 0.7, 0.5, 0.5)) plot(1:100, xaxt="n") par(xaxp=c(0, 100, 10)) # the value is reset at each plot axis(1) and the 100 does not appear. If I run this again: plot(1:100, xaxt="n") axis(1) I'm back with R's default axis and the 100 is present. Anyone on a Mac wants to try? Denis
-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595