text plots?

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

text plots?

Robert Citek

Is there a way to do text plots in R?

I'd like to do some simple XY plots in R with the output in text  
(ascii).  For example, with gnuplot I can do the following:

echo 'set terminal dumb ; plot sin(x)' | gnuplot

To generate a simple sin wave.  Since I connect to a remote Linux  
machine using SSH, being able to generate a rough idea of what a plot  
will look like in text would be of benefit.  I've looked at ?plot, ?
par, and ?plot.default but didn't see anything obvious.

Regards,
- Robert
http://www.cwelug.org/downloads
Help others get OpenSource software.  Distribute FLOSS
for Windows, Linux, *BSD, and MacOS X with BitTorrent

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: text plots?

Gabor Grothendieck
You could transfer the data to MacAnova and do it there.
There is an example here:

http://tolstoy.newcastle.edu.au/R/help/03b/7504.html

Type
  help
in MacAnova to get info on other graphics functions.

On 5/12/06, Robert Citek <[hidden email]> wrote:

>
> Is there a way to do text plots in R?
>
> I'd like to do some simple XY plots in R with the output in text
> (ascii).  For example, with gnuplot I can do the following:
>
> echo 'set terminal dumb ; plot sin(x)' | gnuplot
>
> To generate a simple sin wave.  Since I connect to a remote Linux
> machine using SSH, being able to generate a rough idea of what a plot
> will look like in text would be of benefit.  I've looked at ?plot, ?
> par, and ?plot.default but didn't see anything obvious.
>
> Regards,
> - Robert
> http://www.cwelug.org/downloads
> Help others get OpenSource software.  Distribute FLOSS
> for Windows, Linux, *BSD, and MacOS X with BitTorrent
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: text plots?

François Pinard
In reply to this post by Robert Citek
[Robert Citek]

>Is there a way to do text plots in R?  I'd like to do some simple XY
>plots in R with the output in text  (ascii).  Since I connect to
>a remote Linux machine using SSH, being able to generate a rough idea
>of what a plot will look like in text would be of benefit.

Note that it is easy with SSH to open a graphics connection, you may use
"ssh -X" to force it.  Than, R will show you nice graphics even if run
remotely.

>For example, with gnuplot I can do the following:
>  echo 'set terminal dumb ; plot sin(x)' | gnuplot
>to generate a simple sin wave.  Regards,

Amusing for me that you mention this: I wrote that code, many years ago.
Despite gnuplot was aiming higher graphic output quality on average, my
contribution was readily accepted, and considered useful.

While it is possible to attach images within an email, rough graphics
is sometimes simpler and sufficient.  I do not know how easy (or not) it
would be writing a dumb device for R, but I wish that if someone ever
contributes it, it will be accepted by the core team.

--
François Pinard   http://pinard.progiciels-bpi.ca

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: text plots?

Kevin E. Thorpe
In reply to this post by Robert Citek
This may not help, but if you have S-Plus on the machine you're
connecting to, it has a printer() device for this sort of thing.

Robert Citek wrote:

> Is there a way to do text plots in R?
>
> I'd like to do some simple XY plots in R with the output in text  
> (ascii).  For example, with gnuplot I can do the following:
>
> echo 'set terminal dumb ; plot sin(x)' | gnuplot
>
> To generate a simple sin wave.  Since I connect to a remote Linux  
> machine using SSH, being able to generate a rough idea of what a plot  
> will look like in text would be of benefit.  I've looked at ?plot, ?
> par, and ?plot.default but didn't see anything obvious.
>
> Regards,
> - Robert


--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [hidden email]  Tel: 416.946.8081  Fax: 416.946.3297

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: text plots?

Robert Citek
In reply to this post by Robert Citek

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?

Regards,
- Robert
http://www.cwelug.org/downloads
Help others get OpenSource software.  Distribute FLOSS
for Windows, Linux, *BSD, and MacOS X with BitTorrent

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: text plots?

Kevin E. Thorpe
In reply to this post by François Pinard
François Pinard wrote:

> [Robert Citek]
>
>> Is there a way to do text plots in R?  I'd like to do some simple XY
>> plots in R with the output in text  (ascii).  Since I connect to
>> a remote Linux machine using SSH, being able to generate a rough idea
>> of what a plot will look like in text would be of benefit.
>
> Note that it is easy with SSH to open a graphics connection, you may use
> "ssh -X" to force it.  Than, R will show you nice graphics even if run
> remotely.
>

I had forgotton about that.  I just did a quick test.  I SSHd into my
home PC from my office (it's a 455 MHz PII), started the X11() device
and ran example(xyplot).  I was suprised by the speed.  It was faster
than I expected it to be.

--
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: [hidden email]  Tel: 416.946.8081  Fax: 416.946.3297

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: text plots?

Prof Brian Ripley
In reply to this post by Robert Citek
On Fri, 12 May 2006, Robert Citek wrote:

> Is there a way to do text plots in R?

Not that I know of.  I last used such plots ca 1985, long before R was
conceived of and when student terminal rooms had 80*24 VDUs.

> I'd like to do some simple XY plots in R with the output in text
> (ascii).  For example, with gnuplot I can do the following:
>
> echo 'set terminal dumb ; plot sin(x)' | gnuplot
>
> To generate a simple sin wave.  Since I connect to a remote Linux
> machine using SSH, being able to generate a rough idea of what a plot
> will look like in text would be of benefit.

I routinely use a Linux box remotely, but either view on an X connection
(e.g. from my home to my office, and I have even done internationally), or
write PDF and remote access the file. I even see people using Windows
Terminal Services remotely over quite slow lines.

> I've looked at ?plot, ?par, and ?plot.default but didn't see anything
> obvious.

You need to look at devices (e.g. ?Devices), not how to plot on a device.

BTW, devices do not need to be part of R so anyone could write such a
device and contribute it (in a package).


--
Brian D. Ripley,                  [hidden email]
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: text plots?

Gabor Grothendieck
In reply to this post by Robert Citek
On 5/12/06, Robert Citek <[hidden email]> 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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: text plots?

Gregory Snow
In reply to this post by Robert Citek
There are some very basic interface functions to gnuplot in the
TeachingDemos package that may make option 2 below a little quicker.  Or
even better you could expand them to work better.

The following works on a single windows machine (don't have linux or a
remote machine to test with):

library(TeachingDemos)
x <- runif(100)
y <- rnorm(100)

gp.open()
gp.send('set terminal dumb')
gp.plot(x,y)

# switch to gnuplot window to look at plot

gp.close()


Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[hidden email]
(801) 408-8111
 

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Robert Citek
Sent: Friday, May 12, 2006 9:35 AM
To: [hidden email]
Subject: Re: [R] text plots?


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?

Regards,
- Robert
http://www.cwelug.org/downloads
Help others get OpenSource software.  Distribute FLOSS for Windows,
Linux, *BSD, and MacOS X with BitTorrent

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html