posit-dev / positron

Positron, a next-generation data science IDE
Other
2.48k stars 77 forks source link

Distorted/blurred plots in plot-pane for specific scaling settings #3698

Open strengejacke opened 3 months ago

strengejacke commented 3 months ago

Plots created with ggplot are quite distorted/blurred, in particular labels. See:

image

And also for this small reprex.

ggplot2::ggplot(iris, ggplot2::aes(x = Sepal.Width, y = Sepal.Length)) +
  ggplot2::geom_point()

image

I'm using Positron on Windows 11.

petetronic commented 3 months ago

Thanks for testing out Positron! I was not able to reproduce this issue on Windows 11 with R 4.4.0. Could you please share more about your environment, perhaps the output of sessionInfo() if you can share it, or at least the version of R in use and the versions of libraries loaded?

strengejacke commented 3 months ago

Sure:

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.1 (2024-06-14 ucrt)
#>  os       Windows 11 x64 (build 22631)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  German_Germany.utf8
#>  ctype    German_Germany.utf8
#>  tz       Europe/Berlin
#>  date     2024-07-01
#>  pandoc   3.1.12.3 @ c:\\Program Files\\Positron\\bin\\pandoc/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package      * version    date (UTC) lib source
#>    backports      1.5.0      2024-05-23 [1] CRAN (R 4.4.0)
#>    base64enc      0.1-3      2015-07-28 [1] CRAN (R 4.4.0)
#>    bayestestR   * 0.13.2.2   2024-06-30 [1] local
#>    boot           1.3-30     2024-02-26 [2] CRAN (R 4.4.1)
#>    checkmate      2.3.1      2023-12-04 [1] CRAN (R 4.4.0)
#>    cli            3.6.2      2023-12-11 [1] CRAN (R 4.4.0)
#>    cluster        2.1.6      2023-12-01 [1] CRAN (R 4.4.0)
#>    coda           0.19-4.1   2024-01-31 [1] CRAN (R 4.4.0)
#>    codetools      0.2-20     2024-03-31 [2] CRAN (R 4.4.1)
#>    colorspace     2.1-0      2023-01-23 [1] CRAN (R 4.4.0)
#>    correlation  * 0.8.5      2024-06-16 [1] https://easystats.r-universe.dev (R 4.4.0)
#>    data.table     1.15.4     2024-03-30 [1] CRAN (R 4.4.0)
#>    datawizard   * 0.11.0.4   2024-06-30 [1] Github (easystats/datawizard@ebe48b4)
#>    digest         0.6.35     2024-03-11 [1] CRAN (R 4.4.0)
#>    dplyr          1.1.4      2023-11-17 [1] CRAN (R 4.4.0)
#>    easystats    * 0.7.2.2    2024-06-18 [1] https://easystats.r-universe.dev (R 4.4.0)
#>    effectsize   * 0.8.8.2    2024-06-23 [1] https://easystats.r-universe.dev (R 4.4.0)
#>    emmeans        1.10.2     2024-05-20 [1] CRAN (R 4.4.0)
#>    estimability   1.5.1      2024-05-12 [1] CRAN (R 4.4.0)
#>    evaluate       0.24.0     2024-06-10 [1] CRAN (R 4.4.0)
#>    fansi          1.0.6      2023-12-08 [1] CRAN (R 4.4.0)
#>    fastmap        1.2.0      2024-05-15 [1] CRAN (R 4.4.0)
#>    foreign        0.8-86     2023-11-28 [2] CRAN (R 4.4.1)
#>    Formula        1.2-5      2023-02-24 [1] CRAN (R 4.4.0)
#>    fs             1.6.4      2024-04-25 [1] CRAN (R 4.4.0)
#>    generics       0.1.3      2022-07-05 [1] CRAN (R 4.4.0)
#>    ggeffects    * 1.7.0.2    2024-06-26 [1] local
#>    ggplot2      * 3.5.1      2024-04-23 [1] CRAN (R 4.4.0)
#>    glmmTMB      * 1.1.9      2024-03-20 [1] CRAN (R 4.4.0)
#>    glue           1.7.0      2024-01-09 [1] CRAN (R 4.4.0)
#>    gridExtra      2.3        2017-09-09 [1] CRAN (R 4.4.0)
#>    gtable         0.3.5      2024-04-22 [1] CRAN (R 4.4.0)
#>    Hmisc          5.1-3      2024-05-28 [1] CRAN (R 4.4.0)
#>    htmlTable      2.4.2      2023-10-29 [1] CRAN (R 4.4.0)
#>    htmltools      0.5.8.1    2024-04-04 [1] CRAN (R 4.4.0)
#>    htmlwidgets    1.6.4      2023-12-06 [1] CRAN (R 4.4.0)
#>    insight      * 0.20.1     2024-06-11 [1] CRAN (R 4.4.1)
#>    knitr          1.47       2024-05-29 [1] CRAN (R 4.4.0)
#>    lattice        0.22-6     2024-03-20 [1] CRAN (R 4.4.0)
#>    lifecycle      1.0.4      2023-11-07 [1] CRAN (R 4.4.0)
#>    lme4           1.1-35.4   2024-06-19 [1] CRAN (R 4.4.1)
#>    magrittr       2.0.3      2022-03-30 [1] CRAN (R 4.4.0)
#>    MASS           7.3-60.2   2024-04-26 [2] CRAN (R 4.4.1)
#>    Matrix         1.7-0      2024-04-26 [2] CRAN (R 4.4.1)
#>    mgcv           1.9-1      2023-12-21 [1] CRAN (R 4.4.0)
#>    minqa          1.2.7      2024-05-20 [1] CRAN (R 4.4.0)
#>    modelbased   * 0.8.8      2024-06-11 [1] https://easystats.r-universe.dev (R 4.4.0)
#>    multcomp       1.4-25     2023-06-20 [1] CRAN (R 4.4.0)
#>    munsell        0.5.1      2024-04-01 [1] CRAN (R 4.4.0)
#>    mvtnorm        1.2-5      2024-05-21 [1] CRAN (R 4.4.0)
#>    nlme           3.1-164    2023-11-27 [2] CRAN (R 4.4.1)
#>    nloptr         2.1.0      2024-06-19 [1] CRAN (R 4.4.1)
#>    nnet           7.3-19     2023-05-03 [1] CRAN (R 4.4.0)
#>    numDeriv       2016.8-1.1 2019-06-06 [1] CRAN (R 4.4.0)
#>    parameters   * 0.22.0.1   2024-06-30 [1] local
#>    performance  * 0.12.0.4   2024-06-18 [1] https://easystats.r-universe.dev (R 4.4.0)
#>    pillar         1.9.0      2023-03-22 [1] CRAN (R 4.4.0)
#>    pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.4.0)
#>    purrr          1.0.2      2023-08-10 [1] CRAN (R 4.4.0)
#>    R.cache        0.16.0     2022-07-21 [1] CRAN (R 4.4.0)
#>    R.methodsS3    1.8.2      2022-06-13 [1] CRAN (R 4.4.0)
#>    R.oo           1.26.0     2024-01-24 [1] CRAN (R 4.4.0)
#>    R.utils        2.12.3     2023-11-18 [1] CRAN (R 4.4.0)
#>    R6             2.5.1      2021-08-19 [1] CRAN (R 4.4.0)
#>    Rcpp           1.0.12     2024-01-09 [1] CRAN (R 4.4.0)
#>    report       * 0.5.8.4    2024-06-23 [1] https://easystats.r-universe.dev (R 4.4.0)
#>    reprex         2.1.0      2024-01-11 [1] CRAN (R 4.4.0)
#>    rlang          1.1.4      2024-06-04 [1] CRAN (R 4.4.0)
#>    rmarkdown      2.27       2024-05-17 [1] CRAN (R 4.4.0)
#>    rpart          4.1.23     2023-12-05 [2] CRAN (R 4.4.1)
#>    rstudioapi     0.16.0     2024-03-24 [1] CRAN (R 4.4.0)
#>    sandwich       3.1-0      2023-12-11 [1] CRAN (R 4.4.0)
#>    scales         1.3.0      2023-11-28 [1] CRAN (R 4.4.0)
#>    see          * 0.8.4.6    2024-06-17 [1] https://easystats.r-universe.dev (R 4.4.0)
#>    sessioninfo    1.2.2      2021-12-06 [1] CRAN (R 4.4.0)
#>    stringi        1.8.4      2024-05-06 [1] CRAN (R 4.4.0)
#>    stringr        1.5.1      2023-11-14 [1] CRAN (R 4.4.0)
#>    styler         1.10.3     2024-04-07 [1] CRAN (R 4.4.0)
#>    survival       3.7-0      2024-06-05 [1] CRAN (R 4.4.0)
#>    TH.data        1.1-2      2023-04-17 [1] CRAN (R 4.4.0)
#>    tibble         3.2.1      2023-03-20 [1] CRAN (R 4.4.0)
#>    tidyselect     1.2.1      2024-03-11 [1] CRAN (R 4.4.0)
#>  D TMB            1.9.12     2024-06-19 [1] CRAN (R 4.4.1)
#>    utf8           1.2.4      2023-10-22 [1] CRAN (R 4.4.0)
#>    vctrs          0.6.5      2023-12-01 [1] CRAN (R 4.4.0)
#>    withr          3.0.0      2024-01-16 [1] CRAN (R 4.4.0)
#>    xfun           0.45       2024-06-16 [1] CRAN (R 4.4.1)
#>    xtable         1.8-4      2019-04-21 [1] CRAN (R 4.4.0)
#>    yaml           2.3.8      2023-12-11 [1] CRAN (R 4.4.0)
#>    zoo            1.8-12     2023-04-13 [1] CRAN (R 4.4.0)
#> 
#>  [1] C:/Users/Daniel/AppData/Local/R/win-library/4.4
#>  [2] C:/Program Files/R/R-4.4.1/library
#> 
#>  D ── DLL MD5 mismatch, broken installation.
#> 
#> ──────────────────────────────────────────────────────────────────────────────
strengejacke commented 3 months ago

Here's a reprex, including the data for plotting.

library(ggplot2)
load("positron_issue.RData")

axis_labels <- gsub(
  "(high education|intermediate education|low education), (.*)",
  "\\2",
  levels(pr$x)
)

ggplot(
  pr,
  aes(
    x = forcats::fct_reorder(x, predicted, .desc = TRUE),
    y = predicted,
    ymin = conf.low,
    ymax = conf.high,
    color = group
  )) +
  geom_pointrange(fatten = 2) +
  coord_flip() +
  scale_y_log10(
    limits = c(0.045, 0.4),
    labels = scales::percent,
    breaks = c(0.05, 0.075, 0.1, 0.15, 0.2, 0.3, 0.4)
  ) +
  scale_x_discrete(labels = axis_labels[order(pr$predicted, decreasing = TRUE)]) +
  labs(x = NULL, y = NULL, color = "Education") +
  theme(
    legend.position = "bottom",
    axis.text = element_text(color = "black")
  )

Here is what you see in Positron:

image

This is when you change the scaling of the plot pane to "Landscape":

image

Portrait:

image

Square:

image

positron_issue.zip

strengejacke commented 3 months ago

Positron version info:

Positron Version: 2024.06.1 (system setup) build 2024.06.1-27 Code - OSS Version: 1.90.0 Commit: a893e5b282612ccb2200102957ac38d3c14e5196 Date: 2024-06-26T01:33:58.809Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22631

strengejacke commented 3 months ago

Looks like that it's not a general issue, but only for specific scaling, like auto or fill.

nstrayer commented 3 months ago

Are you using scaling on your monitor? E.g. a "retina" like display?

strengejacke commented 3 months ago

No, it happens on different computers, all 100% scaling and recommended resolution:

image

joshualeond commented 3 months ago

Not sure if this is helpful at all but I'm also experiencing the same issue on Windows 10.

I find that when I change the modes (Landscape/Auto/etc.) and play with the pane width I eventually find a resolution that looks nice. The resolution is definitely not as consistent as it is in RStudio. I'm enjoying the Positron experience a lot though and likely won't go back to RStudio despite this current issue.

joshualeond commented 2 weeks ago

Just wanted to add that this issue may have been resolved. I can't say I've experienced this in a while. Would be interested to hear if @strengejacke is still seeing this.

strengejacke commented 2 weeks ago

No, doesn't seem to be resolved.

Positron Version: 2024.09.0 (system setup) build 27 Code - OSS Version: 1.92.0 Commit: d996153f3be6bcc9af460300e61103425323b973 Date: 2024-09-11T02:38:49.688Z Electron: 30.1.2 Chromium: 124.0.6367.243 Node.js: 20.14.0 V8: 12.4.254.20-electron.0 OS: Windows_NT x64 10.0.22631

image

image

image

The next two are interesting, see the difference between "Fit" and "100%"

image

image