pch="." plots much faster

View: New views
6 Messages — Rating Filter:   Alert me  

pch="." plots much faster

by Charles Plessy-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear list,

I realised by chance when analysing a 1521862 × 8 matrix that plotting
was much faster when using "." as the argument of `pch'. I was just
wondering if there were other ways to get this speed improvement: it is
otherwise quite difficult to explore such big matrices, especially given
that X11 redraws the plot whenever its window is covered/uncovered by
another window, or when I switch virtual desktops.

Best regards,

--
Charles Plessy,
Wakō, Saitama, Japan

______________________________________________
R-help@... 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.

Re: pch="." plots much faster

by Prof Brian Ripley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 13 May 2008, Charles Plessy wrote:

> Dear list,
>
> I realised by chance when analysing a 1521862 × 8 matrix that plotting
> was much faster when using "." as the argument of `pch'.

Why is that surprising?  Drawing a small square is rather easy compared to
a circle, say.

> I was just wondering if there were other ways to get this speed
> improvement: it is otherwise quite difficult to explore such big
> matrices, especially given that X11 redraws the plot whenever its window
> is covered/uncovered by another window, or when I switch virtual
> desktops.

That is a function of your X setup.  R does ask for backing store to be
used, and so it seeems your setup is not doing so. Also, the type="cairo"
in X11() will repaint from a backing pixmap.

You might want to contemplate better ways to visualize 1.5m points.  It is
not clear what plot you are actually doing, but a density plot is likely
to be more informative (especially a 2D pairs plot of densities), or a
hexbin plot (from the BioC package or that name) or ....

>
> Best regards,
>
> --
> Charles Plessy,
> Wakō, Saitama, Japan
>
> ______________________________________________
> R-help@... 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.
>
--
Brian D. Ripley,                  ripley@...
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
______________________________________________
R-help@... 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.

Re: pch="." plots much faster

by Karl Ove Hufthammer-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Prof Brian Ripley:

>> matrices, especially given that X11 redraws the plot whenever its window
>> is covered/uncovered by another window, or when I switch virtual
>> desktops.
>
> That is a function of your X setup.  R does ask for backing store to be
> used, and so it seeems your setup is not doing so.

I believe this is a common problem. I have observed it on all systems and R
versions I've used.

On my Fedora 8 system with R 2.7.0 Patched, the following causes complete
repainting every time you I slightly move a window in front of the graphics
window:

X11(type="Xlib"); n=10^5; plot(rnorm(n),rnorm(n))

Using cairo, the backing pixmap is used (but cairo is extremely slow in
plotting 10^5 points, so that doesn't help much :-/ ).

--
Karl Ove Hufthammer

______________________________________________
R-help@... 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.

Re: pch="." plots much faster

by Prof Brian Ripley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 13 May 2008, Karl Ove Hufthammer wrote:

> Prof Brian Ripley:
>
>>> matrices, especially given that X11 redraws the plot whenever its window
>>> is covered/uncovered by another window, or when I switch virtual
>>> desktops.
>>
>> That is a function of your X setup.  R does ask for backing store to be
>> used, and so it seeems your setup is not doing so.
>
> I believe this is a common problem. I have observed it on all systems and R
> versions I've used.
Well, I've observed it with some window mangers in F8, but I've also seen
other systems where a backing store was used.

> On my Fedora 8 system with R 2.7.0 Patched, the following causes complete
> repainting every time you I slightly move a window in front of the graphics
> window:
>
> X11(type="Xlib"); n=10^5; plot(rnorm(n),rnorm(n))
>
> Using cairo, the backing pixmap is used (but cairo is extremely slow in
> plotting 10^5 points, so that doesn't help much :-/ ).

It does if you use a more suitable plot of 10^5 points.

>
> --
> Karl Ove Hufthammer
>
> ______________________________________________
> R-help@... 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.
>
--
Brian D. Ripley,                  ripley@...
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
______________________________________________
R-help@... 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.

Re: pch="." plots much faster

by Henrik Bengtsson (max 7Mb) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

FYI,

there is also smoothScatter() in the 'geneplotter' package (part of
the Bioconductor.org project).

/Henrik

On Tue, May 13, 2008 at 5:08 AM, Prof Brian Ripley
<ripley@...> wrote:

> On Tue, 13 May 2008, Charles Plessy wrote:
>
>
> > Dear list,
> >
> > I realised by chance when analysing a 1521862 × 8 matrix that plotting
> > was much faster when using "." as the argument of `pch'.
> >
>
>  Why is that surprising?  Drawing a small square is rather easy compared to
> a circle, say.
>
>
>
> > I was just wondering if there were other ways to get this speed
> improvement: it is otherwise quite difficult to explore such big matrices,
> especially given that X11 redraws the plot whenever its window is
> covered/uncovered by another window, or when I switch virtual desktops.
> >
>
>  That is a function of your X setup.  R does ask for backing store to be
> used, and so it seeems your setup is not doing so. Also, the type="cairo" in
> X11() will repaint from a backing pixmap.
>
>  You might want to contemplate better ways to visualize 1.5m points.  It is
> not clear what plot you are actually doing, but a density plot is likely to
> be more informative (especially a 2D pairs plot of densities), or a hexbin
> plot (from the BioC package or that name) or ....
>
>
>
>
> >
> > Best regards,
> >
> > --
> > Charles Plessy,
> > Wakō, Saitama, Japan
> >
> > ______________________________________________
> > R-help@... 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.
> >
> >
>
>  --
>  Brian D. Ripley,                  ripley@...
>  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
> ______________________________________________
>  R-help@... 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.
>
>
______________________________________________
R-help@... 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.

Re: pch="." plots much faster

by Charles Plessy-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le Tue, May 13, 2008 at 01:08:15PM +0100, Prof Brian Ripley a écrit :
>
> That is a function of your X setup.  R does ask for backing store to be
> used, and so it seeems your setup is not doing so. Also, the type="cairo"
> in X11() will repaint from a backing pixmap.

Thanks for the answer.

I have tried to add :
Option "BackingStore" "true"
in /etc/X11/xorg.conf, but it created many display artefacts. I
understand why it was not on by default: it seems that not all graphic card
drives support the option correctly. In the meantime, I have started to
use a R installation that can make cairo graphics and I am very
satisfied of it.

(I also have tried to reduce the complexity of my plots, for instance by
using the unique() function, that works very well with my highly
redundant data).

Have a nice day,

--
Charles Plessy
http://charles.plessy.org
Wakō, Saitama, Japan

______________________________________________
R-help@... 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.
LightInTheBox - Buy quality products at wholesale price