Xavier Prudent
Xavier Prudent

Reputation: 1742

Plotting pixel by pixel with R

For some unfortunate technical reasons, I need to have a pixel plot. For example, let's take this simple plot:

plot(0,0)
Points(x=1:10, y=rep(0,10), cex=1)

I need each dot to be exactly a pixel wide. The size parameter cex does not seem to allow such precision.

Upvotes: 0

Views: 479

Answers (1)

Vlad
Vlad

Reputation: 999

You could use ggplot with the option geom_point(shape = ".").

For example

# generate random dataframe
df <- data.frame(x = runif(100), y = runif(100)) 

# make the figure
ggplot(df) + aes(x = x, y = y) + geom_point(shape = ".") + theme_void()

This will create something like:

enter image description here

Upvotes: 1

Related Questions