Search code examples
rggplot2shinyantialiasing

R shiny - ggplot/ggforce shape renders highly pixellated, how to anti-alias?


I'm using the package ggforce to make particular shapes for an R shiny ggplot (using geom_ellipse and geom_shape). When I run the app from R itself, it renders the shapes nicely with smooth lines/shapes. However, when I actually run the app on the web, it presents differently, with what look like heavily aliased/pixelated lines.

The circle on the left is the web version, whereas the one on the right is the one that runs from R when I test the app directly.

I am wondering how to get the nice, smoother rendering in the web version, without having to do something like rendering the plot as an image.

Any help would be great!

enter image description here


Solution

  • Try to use cairo within the server function

    server <- function(input, output, session){ options(shiny.usecairo=TRUE) ... }
    

    The corresponding package library(Cairo) is required as well.