Adding Axis value to R Plot

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding Axis value to R Plot

AbouEl-Makarim Aboueissa-3
Dear All: good morning



within this code, please see below,


plot(0:1.0, 0:1.0, type = "n",  yaxs = "i", xaxs = "i", xaxt = "n", yaxt =
"n", xlab = "Age", ylab = "Distance (ft)",  cex.lab=1.5)
grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2)



Is there a way to force R to add the following Axis ticks to this plot


xticks <- c(15,25,35,45,55,65,75,85)
yticks <- c(300,400,500,600)



with many thanks
abou
______________________


*AbouEl-Makarim Aboueissa, PhD*

*Professor of Statistics*

*Department of Mathematics and Statistics*
*University of Southern Maine*

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Axis value to R Plot

Bert Gunter-2
See ?plot.default, where it says:

axes

a logical value indicating whether both axes should be drawn on the plot.
Use graphical parameter
<http://127.0.0.1:29349/help/library/graphics/help/graphical%20parameter>
"xaxt" or "yaxt" to suppress just one of the axes.
 and use the "at" argument of ?axis to draw the axis and add ticks where
you like.

Cheers,
Bert




Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Jun 25, 2018 at 7:36 AM, AbouEl-Makarim Aboueissa <
[hidden email]> wrote:

> Dear All: good morning
>
>
>
> within this code, please see below,
>
>
> plot(0:1.0, 0:1.0, type = "n",  yaxs = "i", xaxs = "i", xaxt = "n", yaxt =
> "n", xlab = "Age", ylab = "Distance (ft)",  cex.lab=1.5)
> grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2)
>
>
>
> Is there a way to force R to add the following Axis ticks to this plot
>
>
> xticks <- c(15,25,35,45,55,65,75,85)
> yticks <- c(300,400,500,600)
>
>
>
> with many thanks
> abou
> ______________________
>
>
> *AbouEl-Makarim Aboueissa, PhD*
>
> *Professor of Statistics*
>
> *Department of Mathematics and Statistics*
> *University of Southern Maine*
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Axis value to R Plot

Jim Lemon-4
In reply to this post by AbouEl-Makarim Aboueissa-3
Hi Abou,
You can't display an axis if it is not in the range of the plot. I
think you want:

plot(0,type="n",yaxs="i",xaxs="i",xaxt="n",yaxt="n",xlim=c(15,85),
 ylim=c(300,600),xlab="Age",ylab="Distance (ft)",cex.lab=1.5)
grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2)
xticks <- c(15,25,35,45,55,65,75,85)
yticks <- c(300,400,500,600)
axis(1,at=xticks)
axis(2,at=yticks)

Note the addition of xlim and ylim arguments.

Jim

On Tue, Jun 26, 2018 at 12:36 AM, AbouEl-Makarim Aboueissa
<[hidden email]> wrote:

> Dear All: good morning
>
>
>
> within this code, please see below,
>
>
> plot(0:1.0, 0:1.0, type = "n",  yaxs = "i", xaxs = "i", xaxt = "n", yaxt =
> "n", xlab = "Age", ylab = "Distance (ft)",  cex.lab=1.5)
> grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2)
>
>
>
> Is there a way to force R to add the following Axis ticks to this plot
>
>
> xticks <- c(15,25,35,45,55,65,75,85)
> yticks <- c(300,400,500,600)
>
>
>
> with many thanks
> abou
> ______________________
>
>
> *AbouEl-Makarim Aboueissa, PhD*
>
> *Professor of Statistics*
>
> *Department of Mathematics and Statistics*
> *University of Southern Maine*
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Adding Axis value to R Plot

AbouEl-Makarim Aboueissa-3
Dear Jim:

many thanks

abou

______________________


*AbouEl-Makarim Aboueissa, PhD*

*Professor of Statistics*

*Department of Mathematics and Statistics*
*University of Southern Maine*


On Mon, Jun 25, 2018 at 7:25 PM, Jim Lemon <[hidden email]> wrote:

> Hi Abou,
> You can't display an axis if it is not in the range of the plot. I
> think you want:
>
> plot(0,type="n",yaxs="i",xaxs="i",xaxt="n",yaxt="n",xlim=c(15,85),
>  ylim=c(300,600),xlab="Age",ylab="Distance (ft)",cex.lab=1.5)
> grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2)
> xticks <- c(15,25,35,45,55,65,75,85)
> yticks <- c(300,400,500,600)
> axis(1,at=xticks)
> axis(2,at=yticks)
>
> Note the addition of xlim and ylim arguments.
>
> Jim
>
> On Tue, Jun 26, 2018 at 12:36 AM, AbouEl-Makarim Aboueissa
> <[hidden email]> wrote:
> > Dear All: good morning
> >
> >
> >
> > within this code, please see below,
> >
> >
> > plot(0:1.0, 0:1.0, type = "n",  yaxs = "i", xaxs = "i", xaxt = "n", yaxt
> =
> > "n", xlab = "Age", ylab = "Distance (ft)",  cex.lab=1.5)
> > grid(nx = 10, ny = 10, col = "lightgray", lty = "dotted", lwd = 2)
> >
> >
> >
> > Is there a way to force R to add the following Axis ticks to this plot
> >
> >
> > xticks <- c(15,25,35,45,55,65,75,85)
> > yticks <- c(300,400,500,600)
> >
> >
> >
> > with many thanks
> > abou
> > ______________________
> >
> >
> > *AbouEl-Makarim Aboueissa, PhD*
> >
> > *Professor of Statistics*
> >
> > *Department of Mathematics and Statistics*
> > *University of Southern Maine*
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.