I cannot plot in the Plots Panel. All plots open in Viewer Panel

In the new version of RStudio (1.1.456), all my plots I created by ggplot open in an external window, instead of Plots Panel. I do not know how to navigate previous plots created in this window. How can I plot my ggplot graphs in the Plots Panel?

Thanks.

1 Like

I'm not familiar with that version of RStudio, but it sounds pretty old. The current production version is 2024.04.1-748. You might want to try that.

1 Like

Hi @cem ,

Could you share a screenshot that shows the behavior you're describing, including code that normally should have appeared in the plots panel?

1 Like

I installed 2024.04.1-748 build. The version as reported in Help>About Studio is 1.1.456. Don't ask me why!

1 Like

Hello Dromono.

Here is the code to produce the plots:
xLabel = "ID"
yLabel = bquote( Volume "~(mm^3))
gTitle = "Volumes by Groups"
sTitle = "Sample 5"
sCaption = "Company"

for (j in 1:num_covariants) {
value <- animals[, c("ID", covariant_name[j], "GroupID")]
colnames(value)[2] <- "value"
gTitle = covariant_name[j]
p <- ggplot(value, aes(x = ID, y = value, fill = GroupID, color = GroupID)) +
geom_col(position = "dodge", width = 0.5, color = "lightgrey", linewidth = 0.1) +
facet_wrap(~ GroupID, scales = "free_x") +
labs(x = xLabel, y = yLabel, title = gTitle, subtitle = sTitle, caption = sCaption, fill = "Group ID") +
TMTheme() + scale_fill_manual(values = TMColors, name = "Group ID") +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Dark2") +
theme(strip.text.x = element_text(size = 12, face = "bold"))
p
}

dev.list()
windows
2

I hope this is enough.

1 Like

Sorry, what I was asking (or at least intended to ask) was if you could 1) run your code, and then 2) take a screenshot of your full RStudio window immediately afterwards and share it here. Could you do that?

1 Like

Dramano, I am sorry, I misunderstood. The code is 630 lines long. I cannot create one single = screenshot,+, so there would be many screenshots. Will this do? Maybe I can provide more useful information if you tell me what you are after. The Graphics device is 2. Why>?. I close it (dev.off()), then open one one (dev, new()). PLots are still openned in 2!

1 Like

Thank you, @cem — this is exactly what I meant.

Could you run this code and let us know what happens?

dev.off()
value <- animals[, c("ID", covariant_name[1], "GroupID")]
colnames(value)[2] <- "value"
gTitle = covariant_name[1]
p <- ggplot(value, aes(x = ID, y = value, fill = GroupID, color = GroupID)) +
geom_col(position = "dodge", width = 0.5, color = "lightgrey", linewidth = 0.1) +
facet_wrap(~ GroupID, scales = "free_x") +
labs(x = xLabel, y = yLabel, title = gTitle, subtitle = sTitle, caption = sCaption, fill = "Group ID") +
TMTheme() + scale_fill_manual(values = TMColors, name = "Group ID") +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Dark2") +
theme(strip.text.x = element_text(size = 12, face = "bold"))
p
1 Like

Same thing!

1 Like

And if you rerun the same code again and take another screenshot?

Or better, could you run this?

while (!is.null(dev.list())){dev.off()}
value <- animals[, c("ID", covariant_name[1], "GroupID")]
colnames(value)[2] <- "value"
gTitle = covariant_name[1]
p <- ggplot(value, aes(x = ID, y = value, fill = GroupID, color = GroupID)) +
geom_col(position = "dodge", width = 0.5, color = "lightgrey", linewidth = 0.1) +
facet_wrap(~ GroupID, scales = "free_x") +
labs(x = xLabel, y = yLabel, title = gTitle, subtitle = sTitle, caption = sCaption, fill = "Group ID") +
TMTheme() + scale_fill_manual(values = TMColors, name = "Group ID") +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Dark2") +
theme(strip.text.x = element_text(size = 12, face = "bold"))
p
1 Like

The same is true in every run: it closes the open window from the previous run, then it opens in a new external window (device=2)!
cem

1 Like

Could you run it and post the screenshot again?

1 Like

Certainly. It's the same. One thing I noticed, if it matters, is that before, there was no terminal window behind RStudio IDE. Now, there is a black terminal each time I open RStudio.

1 Like

Thank you, @cem , and I have one more question for now: Could you run

option(device = 'RStudioGD')
dev.cur()
dev.list()

and post a screenshot of the output?

And after that, could you also post the output from these?

sessionInfo()
RStudio.Version()
1 Like

Hello Drango, Thank you for your help. here are the results:

option(device = 'RStudioGD')
Error in option(device = "RStudioGD") : could not find function "option"
In addition: Warning message:
R graphics engine version 16 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.
dev.cur()
null device
1
dev.list()
NULL
sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] vctrs_0.6.5 cli_3.6.2 TH.data_1.1-2 rlang_1.1.2 generics_0.1.3 glue_1.6.2 zoo_1.8-12
[8] colorspace_2.1-0 scales_1.3.0 fansi_1.0.6 grid_4.3.2 munsell_0.5.0 tibble_3.2.1 MASS_7.3-60
[15] yaml_2.3.8 mvtnorm_1.2-4 lifecycle_1.0.4 compiler_4.3.2 multcomp_1.4-25 codetools_0.2-19 dplyr_1.1.4
[22] sandwich_3.1-0 pkgconfig_2.0.3 rstudioapi_0.15.0 lattice_0.22-5 R6_2.5.1 tidyselect_1.2.0 utf8_1.2.4
[29] pillar_1.9.0 splines_4.3.2 magrittr_2.0.3 Matrix_1.6-4 tools_4.3.2 gtable_0.3.4 survival_3.5-7
[36] ggplot2_3.4.4

RStudio.Version()
$citation
To cite RStudio in publications use:

RStudio Team (2016). RStudio: Integrated Development for R. RStudio, Inc., Boston, MA URL http://www.rstudio.com/.

A BibTeX entry for LaTeX users is

@Manual{,
title = {RStudio: Integrated Development Environment for R},
author = {{RStudio Team}},
organization = {RStudio, Inc.},
address = {Boston, MA},
year = {2016},
url = {http://www.rstudio.com/},
}

$mode
[1] "desktop"

$version
[1] ‘1.1.456’

1 Like

Sorry — typo: should be options(). Could you rerun the first three lines?

1 Like

I just noticed this in the ouput, so it looks like the question is why an old version of RStudio is being installed.

1 Like

options(device = 'RStudioGD')
dev.cur()
windows
2
dev.list()
windows
2

what do you mean old version of Rstudio? This is what I have:


Is this an old version?

1 Like

This version dates from 2018:

1 Like

I downloaded this version from https://posit.co/download/rstudio-desktop/

image
Could you please provide a proper site to download?

1 Like