Hi, I posted this on the Google Group for ggplot2 but got no response. https://groups.google.com/g/ggplot2/c/441srnt6RZU So I hope someone can help me here instead?! - If I don't use the coord_fixed() then all the background is yellow as expected. But I need to coord_fixed() and then it adds a little white around my plot. Is it possible to avoid the white and use coord_fixed() ? Here is a "Minimal, Reproducible Example": library(ggplot2) g <- ggplot() + theme( plot.background = element_rect(fill = "yellow2"), panel.background = element_rect(fill = "yellow2"), ) g <- g + coord_fixed() g Regards Martin M. S. Pedersen
ggplot2::coord_fixed() margin problem
7 messages · Martin Møller Skarbiniks Pedersen, Rui Barradas, Jeff Newmiller +1 more
Hello, I am not sure I understand the problem. With coord_fixed() both axis have the same length and the plot is a square. When resizing the plot window the white areas can be on top/bottom if the window height is bigger than its width or to the left/right if it's the other way around. Does this answer the question? Hope this helps, Rui Barradas ?s 12:22 de 20/12/20, Martin M?ller Skarbiniks Pedersen escreveu:
Hi, I posted this on the Google Group for ggplot2 but got no response. https://groups.google.com/g/ggplot2/c/441srnt6RZU So I hope someone can help me here instead?! - If I don't use the coord_fixed() then all the background is yellow as expected. But I need to coord_fixed() and then it adds a little white around my plot. Is it possible to avoid the white and use coord_fixed() ? Here is a "Minimal, Reproducible Example": library(ggplot2) g <- ggplot() + theme( plot.background = element_rect(fill = "yellow2"), panel.background = element_rect(fill = "yellow2"), ) g <- g + coord_fixed() g Regards Martin M. S. Pedersen [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On Sun, 20 Dec 2020 at 17:43, Rui Barradas <ruipbarradas at sapo.pt> wrote:
Thank you for trying to answer my question.
I am not sure I understand the problem. With coord_fixed() both axis have the same length and the plot is a square. When resizing the plot window the white areas can be on top/bottom if the window height is bigger than its width or to the left/right if it's the other way around.
Yes.
Does this answer the question?
Nope.
I really need the added space as the same color as the plot.background
(yellow2) in the example below.
However the code below generates a small white space. I was expected it to
be the
same as the plot.background color.
library(ggplot2)
g <-
ggplot() +
theme(
plot.background = element_rect(fill = "yellow2"),
panel.background = element_rect(fill = "yellow2"),
)
g <- g + coord_fixed()
g
Regards
Martin
Perhaps ?expansion can help?
On December 20, 2020 9:00:09 AM PST, "Martin M?ller Skarbiniks Pedersen" <traxplayer at gmail.com> wrote:
On Sun, 20 Dec 2020 at 17:43, Rui Barradas <ruipbarradas at sapo.pt> wrote: Thank you for trying to answer my question.
I am not sure I understand the problem. With coord_fixed() both axis have the same length and the plot is a square. When resizing the plot window the white areas can be on top/bottom if the window height is bigger than its width or to the left/right if it's the other way around.
Yes.
Does this answer the question?
Nope.
I really need the added space as the same color as the plot.background
(yellow2) in the example below.
However the code below generates a small white space. I was expected it
to
be the
same as the plot.background color.
library(ggplot2)
g <-
ggplot() +
theme(
plot.background = element_rect(fill = "yellow2"),
panel.background = element_rect(fill = "yellow2"),
)
g <- g + coord_fixed()
g
Regards
Martin
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Sent from my phone. Please excuse my brevity.
On 20/12/2020 12:00 p.m., Martin M?ller Skarbiniks Pedersen wrote:
On Sun, 20 Dec 2020 at 17:43, Rui Barradas <ruipbarradas at sapo.pt> wrote: Thank you for trying to answer my question.
I am not sure I understand the problem. With coord_fixed() both axis have the same length and the plot is a square. When resizing the plot window the white areas can be on top/bottom if the window height is bigger than its width or to the left/right if it's the other way around.
Yes.
Does this answer the question?
Nope.
I really need the added space as the same color as the plot.background
(yellow2) in the example below.
However the code below generates a small white space. I was expected it to
be the
same as the plot.background color.
library(ggplot2)
g <-
ggplot() +
theme(
plot.background = element_rect(fill = "yellow2"),
panel.background = element_rect(fill = "yellow2"),
)
g <- g + coord_fixed()
g
Set the background when you open the graphics device. Assuming you've run the code above, dev.new(bg = "yellow2") g You'll still see the outline of the square; I don't know ggplot2 well enough to know if that can be removed. Duncan Murdoch
Hello, Is it this? plot.background = element_rect(colour = "yellow2", fill = "yellow2") The small white space goes away. Hope this helps, Rui Barradas ?s 17:00 de 20/12/20, Martin M?ller Skarbiniks Pedersen escreveu:
On Sun, 20 Dec 2020 at 17:43, Rui Barradas <ruipbarradas at sapo.pt> wrote: Thank you for trying to answer my question.
I am not sure I understand the problem. With coord_fixed() both axis have the same length and the plot is a square. When resizing the plot window the white areas can be on top/bottom if the window height is bigger than its width or to the left/right if it's the other way around.
Yes.
Does this answer the question?
Nope.
I really need the added space as the same color as the plot.background
(yellow2) in the example below.
However the code below generates a small white space. I was expected it to
be the
same as the plot.background color.
library(ggplot2)
g <-
ggplot() +
theme(
plot.background = element_rect(fill = "yellow2"),
panel.background = element_rect(fill = "yellow2"),
)
g <- g + coord_fixed()
g
Regards
Martin
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
That works with my suggestion:
g <-
ggplot() +
theme(
plot.background = element_rect(fill = "yellow2", colour = "yellow2"),
panel.background = element_rect(fill = "yellow2"),
)
g <- g + coord_fixed()
dev.new(bg = "yellow2")
g # For a pure yellow plot window
Duncan Murdoch
On 20/12/2020 1:21 p.m., Rui Barradas wrote:
Hello, Is it this? plot.background = element_rect(colour = "yellow2", fill = "yellow2") The small white space goes away. Hope this helps, Rui Barradas ?s 17:00 de 20/12/20, Martin M?ller Skarbiniks Pedersen escreveu:
On Sun, 20 Dec 2020 at 17:43, Rui Barradas <ruipbarradas at sapo.pt> wrote: Thank you for trying to answer my question.
I am not sure I understand the problem. With coord_fixed() both axis have the same length and the plot is a square. When resizing the plot window the white areas can be on top/bottom if the window height is bigger than its width or to the left/right if it's the other way around.
Yes.
Does this answer the question?
Nope.
I really need the added space as the same color as the plot.background
(yellow2) in the example below.
However the code below generates a small white space. I was expected it to
be the
same as the plot.background color.
library(ggplot2)
g <-
ggplot() +
theme(
plot.background = element_rect(fill = "yellow2"),
panel.background = element_rect(fill = "yellow2"),
)
g <- g + coord_fixed()
g
Regards
Martin
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.