exaexa / scattermore

very fast scatterplots for R
https://exaexa.github.io/scattermore/
GNU General Public License v3.0
238 stars 7 forks source link

How to add points to existing plot with scattermoreplot? #23

Open scienception opened 1 year ago

scienception commented 1 year ago

I created a plot with scattermoreplot, and want to add additional points in every for loop iteration. Is there such functionality such as adding points() to a plot() plot?

exaexa commented 1 year ago

Hi, yes there is. There are a few ways to do that:

The best way probably depends on your use-case -- what are (roughly) the point amounts that you want to add in each iteration?

exaexa commented 1 year ago

PS I just realized we also have a vignette that contains some relevant code -- the merging of the intermediate layers is described roughly around here: https://exaexa.github.io/scattermore/articles/low_level_interface.html#merging-rgbwt-and-rgba-layers

scienception commented 1 year ago

Thank you! Is it possible to pass a vector for pointsize in geom_scattermost(count_pairs_matrix, pointsize=2)? I need the points to have variable size (depending on some count). Basically I want the size of the point to increment with how many observations for that (x,y) point I got.

exaexa commented 1 year ago

no, unfortunately not, the API is made for single-pixel operations only (for speed) and you are supposed to expand the points after that. (The logic there is that for actual big data, expanding single pixels is much faster than plotting lots if large points.)

The options are:

As a quick question, how many points (roughly) are you plotting in total? Scattermore is specialized for amounts where point sizes typically do not matter anymore; which is exactly why doing "precise" stuff like this gets complex.

Cf. this issue: https://github.com/exaexa/scattermore/issues/18