[R] Plot in cartesian plane

Charles C. Berry cberry at tajo.ucsd.edu
Wed Aug 18 07:14:47 CEST 2010


On Wed, 18 Aug 2010, Pablo Cerdeira wrote:

> Hi all,
>
> I'm trying to plot this two curves in a single cartesian plane, but when I
> plot the first one, the plot appears with no negative "y" value. When I plot
> the second curve, it almost does not apear in the graph.
>
> I was trying the plot.window but with no success.
>
> Can someone help me with this?

The answer is in

 	?par

but it requires a bit of deduction.  Start with the description of yaxs, 
which refers to xaxs. Notice what the xaxs paragraph says about xlim. If 
you can figure out that there is also a ylim arg, then you are pretty much 
finished. Something like

 	plot( f, -10, 10, ylim=c(-100,100) )

will reveal both curves.

xlim and ylim also appear briefly in R-Intro ni Appendix A.

FWIW, one can use xlim and ylim to 'zoom in' on a section of a plot.

HTH,

Chuck

>
> If possible, I'd like to plot this curves in a perfect cartesian plane.
>
> f = function(x) {
>  x^2
> }
> f2 = function(x) {
>  -x^2
> }
>
> plot(f,-10,10)
> abline(h=0, v=0, col = "gray60")
> curve(f2,col="orange", add=T)
>
> Thanks in advanced!
>
>
> *pablo de camargo cerdeira*
> pablo.cerdeira at gmail.com | pablo at fgv.br
> Phone: +55-(21)-3799-6065
> [image: Facebook] <http://www.facebook.com/pablo.cerdeira>[image:
> LinkedIn]<http://br.linkedin.com/in/pablocerdeira>[image:
> Google] <http://www.google.com/profiles/pablo.cerdeira>
> [image: Google Talk/]pablo.cerdeira [image: Skype/]pablocerdeira
>
> 	[[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.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901



More information about the R-help mailing list