[R] text plots?

Gabor Grothendieck ggrothendieck at gmail.com
Fri May 12 17:50:44 CEST 2006


On 5/12/06, Robert Citek <rwcitek at alum.calberkeley.org> wrote:
>
> On May 12, 2006, at 9:57 AM, Robert Citek wrote:
> > Is there a way to do text plots in R?
>
>  From the responses so far, the short answer appears to be, no.
>
> That appears to leave two options for viewing plots on a remote machine:
>
> 1) use X11 forwarding (requires an X11 server and that X11 forwarding
> be enabled), although the plots won't be in text.
>
> 2) output the data to a file and use another program to plot the data
> as text, e.g. MacAnova or gnuplot.
>
> Is that a fair summary?

You could also write your own function, e.g. the following is not
very sophisticated, e.g. no axes, but if you are just looking for something
simple something along these lines may be sufficient:

printplot <- function(x,y, wx = 25, wy = 25, dot = "+") {
	xx <- round((wx-1) * (x - min(x)) / (max(x) - min(x))) + 1
	yy <- round((wy-1) * (y - min(y)) / (max(y) - min(y))) + 1
	slate <- matrix(" ", wx, wy)
	slate[cbind(xx,yy)] <- dot
	for(j in wy:1) cat(slate[j,], "\n", sep = "")
}
printplot(x = 1:10, y = (1:10)^2)  # test




More information about the R-help mailing list