Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A blank plot is producted with plot #58

Open
SficPan opened this issue Jul 3, 2023 · 5 comments
Open

A blank plot is producted with plot #58

SficPan opened this issue Jul 3, 2023 · 5 comments

Comments

@SficPan
Copy link

SficPan commented Jul 3, 2023

When I run:
graph1 <- ggplot(a4,mapping = aes(Day,x_value,colour=factor(patient)))+
geom_line()+
guides(color=guide_legend(title = "Patient"))+
scale_y_break(c(0.3,0.75), scales = 1.5)+
scale_y_break(c(1.55,2.75), scales = 1.5)
The variable graph1 is included with two plots with one blank. I don't know how to separate it from graph1 so it may cause some inconvenience in Rmarkdown.

@GuangchuangYu
Copy link
Member

try

print(graph1)

in Rmarkdown code trunk.

@SficPan
Copy link
Author

SficPan commented Jul 5, 2023

it doesn't work...

@GuangchuangYu
Copy link
Member

We can't reproduce your issue.

You can check the vignette of ggbreak, https://cran.r-project.org/web/packages/ggbreak/vignettes/ggbreak.html, which was generated by Rmarkdown file and it works fine.

@jayoung
Copy link

jayoung commented Dec 19, 2024

@SficPan I experienced this too, but after I 'knit' the Rmd doc the blank plot is not visible at all. From my perspective that means I don't really care about it - it's mildly annoying, but I can live with it.

@GuangchuangYu - I think @SficPan meant that within the Rstudio window, when you run a code chunk, you see two thumbnail plots - the blank plot, and then the plot we care about. Only the good plot appears when rendering the Rmd (I tried html and github_document).

Here is a screen shot. The thumbnails are right below the code chunk. I'll put the actual code in a separate comment

Screenshot 2024-12-18 at 7 09 19 PM

@jayoung
Copy link

jayoung commented Dec 19, 2024

---
title: "ggbreaks"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
library(ggplot2)
library(ggbreak)
library(patchwork)
```

```{r}
set.seed(2019-01-19)
d <- data.frame(x = 1:20,
y = c(rnorm(5) + 4, rnorm(5) + 20, rnorm(5) + 5, rnorm(5) + 22)
)

p1 <- ggplot(d, aes(y, x)) + geom_col(orientation="y")
d2 <- data.frame(x = c(2, 18), y = c(7, 26), label = c("hello", "world"))
p2 <- p1 + scale_x_break(c(7, 17)) +
geom_text(aes(y, x, label=label), data=d2, hjust=1, colour = 'firebrick') +
xlab(NULL) + ylab(NULL) + theme_minimal()

p1 + p2
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants