I'm running Rstudio 2022.07.1 Build 554 on a Windows 10 machine.
I use plot(...) + polygon(..., col = rgb(0,0,0,0.2), border = NA) to plot a time series with transparent error bars as part of a shiny app.
When I run the shiny app locally, I do not see the polygon on the browser, unless I set alpha=1.
When I run the app from shinyapps it works with alpha=0.2, so that excludes a problem with the code.
Transparency works on the RStudio viewer pane, but not on the browser (run external).
I have tried Firefox and Edge.
To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
After playing around with this example, I realized that when the error bars are too large, the polygon is not drawn locally, but it still does on shinyapps. Check this by setting the error bar sd at 0.5 and iterate.
The error bars size may not be the full story, because in my shiny app the user can zoom in/out the series and the polygon is never visible, whereas in shinyapps it is.
On my laptop (i.e. local) on both chrome and edge I do see a polygon, even with the alpha at 0.2
As I can't reproduce this problem I don't know how to help you solve it...
The only issue I can see is when your input$error gets large,as you mention in your second post) then the polygon cant fit within the confines of the plot, and perhaps its clipped away and not drawn ? changing the plot limits ylim, would address that
Thanks for your answer!
Indeed, when running the app from local on Windows and on the browser, the error bar size is what determines if the polygon is drawn (without clipping) or not at all.
The thing is that from shinyapps and the same browser, the polygon is always being drawn , even if it's clipped, that's perfectly OK to me.
Are you not reproducing this?
I just run the example on a different linux machine (local on Firefox) and the polygon is always drawn as well, even when setting huge error bars.
So I suspect there is something with the Windows version of RStudio Desktop.
The transparent polygon is not drawn on the Windows' RStudio viewer pane either when error bars are too large, for instance St. Dev. error bars = 1 in the example.
If alpha = 1 then the solid polygon is always drawn with any error bar size.
Can anyone reproduce this? And in that case, should this be considered a bug?
Fixed by changing the PNG device to type = cairo or type = cairo-png in the renderPlot options.
Transparency does not work for me when the PNG device is forced to type = windows, so I guess that's the default value on my RStudio IDE Windows.