

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ggplot2/5c0085b0-79ce-434a-aced-608735fd267en%40googlegroups.com.
David,
Thanks for your question as it made me think and search for packages and options that might do what you want. Oddly, centering is not something I see the packages caring about! And, of course, sometimes you can get what you want by thinking outside the box. I note that if you are putting your graphs into a program that allows tables and centering, such as WORD or EXCEL, it becomes fairly easy to make an (invisible border?) table with the number of rows/columns you need and place images where you want and align some to be centered, horizontally and/or vertically within their cell. The sizes of the images as saved would remain fixed.
But if you want to remain within a package like patchwork, the documentation does suggest possibilities to get what you want albeit you might need to center it yourself. I am looking at this page, for example:
https://patchwork.data-imaginist.com/articles/guides/layout.html
There seem to be ways to ask it for a component to remain fixed and not be stretched. There is a method allowing inset_element() to place an image overlapping or within an image and I wonder if it could also be used to place it below the current row into an empty row and carefully offset to be in the middle.
The next clip indicates you can:
Further, inset_element() allows you to place the inset below the previous plot, should you choose to, and controlling clipping and tagging in the same way as wrap_elements().
p3 + inset_element(p1, left = 0.5, bottom = 0, right = 1, top = 0.5,
on_top = FALSE, align_to = 'full')
And note you can set heights and widths in some of the supplied functions to be the same for all as in:
plot_layout(widths=c(2,1))
I have to admit that what you want is fairly basic and you wonder why it is not already touted as a built-in feature somewhere. People do like having things centered. What I have done in the past when the bottom row was not full is to play various games to fill it somewhat. This can include putting in an image of the author, putting in (large) text with some useful or useless phrases perhaps about the problem or methods used or even move something like the guides into that empty slot.
Good Luck with finding a solution that works for you.
Avi
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ggplot2/958b7e64-75ca-437a-8822-ba7d10db5c63n%40googlegroups.com.

David,
Thanks for your question as it made me think and search for packages and options that might do what you want. Oddly, centering is not something I see the packages caring about! And, of course, sometimes you can get what you want by thinking outside the box. I note that if you are putting your graphs into a program that allows tables and centering, such as WORD or EXCEL, it becomes fairly easy to make an (invisible border?) table with the number of rows/columns you need and place images where you want and align some to be centered, horizontally and/or vertically within their cell. The sizes of the images as saved would remain fixed.
But if you want to remain within a package like patchwork, the documentation does suggest possibilities to get what you want albeit you might need to center it yourself. I am looking at this page, for example:
https://patchwork.data-imaginist.com/articles/guides/layout.html
There seem to be ways to ask it for a component to remain fixed and not be stretched. There is a method allowing inset_element() to place an image overlapping or within an image and I wonder if it could also be used to place it below the current row into an empty row and carefully offset to be in the middle.
The next clip indicates you can:
Further, inset_element() allows you to place the inset below the previous plot, should you choose to, and controlling clipping and tagging in the same way as wrap_elements().
p3 + inset_element(p1, left = 0.5, bottom = 0, right = 1, top = 0.5,
on_top = FALSE, align_to = 'full')
And note you can set heights and widths in some of the supplied functions to be the same for all as in:
plot_layout(widths=c(2,1))
I have to admit that what you want is fairly basic and you wonder why it is not already touted as a built-in feature somewhere. People do like having things centered. What I have done in the past when the bottom row was not full is to play various games to fill it somewhat. This can include putting in an image of the author, putting in (large) text with some useful or useless phrases perhaps about the problem or methods used or even move something like the guides into that empty slot.
Good Luck with finding a solution that works for you.
Avi
On Mon, Jan 3, 2022 at 7:03 AM David Kaplan <cubsf...@gmail.com> wrote:
David,
Thanks for your question as it made me think and search for packages and options that might do what you want. Oddly, centering is not something I see the packages caring about! And, of course, sometimes you can get what you want by thinking outside the box. I note that if you are putting your graphs into a program that allows tables and centering, such as WORD or EXCEL, it becomes fairly easy to make an (invisible border?) table with the number of rows/columns you need and place images where you want and align some to be centered, horizontally and/or vertically within their cell. The sizes of the images as saved would remain fixed.
But if you want to remain within a package like patchwork, the documentation does suggest possibilities to get what you want albeit you might need to center it yourself. I am looking at this page, for example:
https://patchwork.data-imaginist.com/articles/guides/layout.html
There seem to be ways to ask it for a component to remain fixed and not be stretched. There is a method allowing inset_element() to place an image overlapping or within an image and I wonder if it could also be used to place it below the current row into an empty row and carefully offset to be in the middle.
The next clip indicates you can:
Further, inset_element() allows you to place the inset below the previous plot, should you choose to, and controlling clipping and tagging in the same way as wrap_elements().
p3 + inset_element(p1, left = 0.5, bottom = 0, right = 1, top = 0.5,
on_top = FALSE, align_to = 'full')
And note you can set heights and widths in some of the supplied functions to be the same for all as in:
plot_layout(widths=c(2,1))
I have to admit that what you want is fairly basic and you wonder why it is not already touted as a built-in feature somewhere. People do like having things centered. What I have done in the past when the bottom row was not full is to play various games to fill it somewhat. This can include putting in an image of the author, putting in (large) text with some useful or useless phrases perhaps about the problem or methods used or even move something like the guides into that empty slot.
Good Luck with finding a solution that works for you.
Avi
I’m not quite sure how I got on this list but a few quick observations.
A while back I found myself with lots of time invested in a ggplot graphic but no way to implement a tweak I needed to the final image.
I’ve always found ggplot a bit cryptic to use, despite Hadley’s goal of ease of use.
I ended up using the core routines that Hadley uses, ‘grobs’, I think, to solve my problem.
(There’s a book called R Graphics by Murrow that gets into these grob details.)
I don’t even really know what I did – it was trial and error all the way. Finally something worked.
After that experience, I decided to not use ggplot any more. Harsh, I know.
Since then I’ve mostly stayed with Base Graphics – I’ve never found anything I couldn’t do in Base, even if it usually takes more steps.
So, if you’re really desperate, you might get Murrow’s book and figure out how to work on the deeper level ggplot objects.
I wish I had something better to say, but that’s my 2 cents.
Brad
From:
ggp...@googlegroups.com <ggp...@googlegroups.com> on behalf of Avi Gross <avi.e...@gmail.com>
Date: Tuesday, January 4, 2022 at 7:08 AM
To: David Kaplan <cubsf...@gmail.com>
Cc: ggplot2 <ggp...@googlegroups.com>
Subject: Re: Centering a plot
dAVId,
Just to waste some time I tried their offset method but it takes fin tuning using numbers I am not understanding. The following sort of works for me when I added some padding on bottom and did the offset relative to the second row, first column trying to dangle another plot just below it and centered. It can let you all kinds of weird things and is neither easy or a good automated technique.
ridge +
laplace +
horseshoe +
inset_element(spikeSlab, left = .4, bottom = -1.9, right = 1.6, top = 0) +
FinnHorseshoe +
plot_spacer() +
plot_spacer() +
plot_spacer() +
plot_layout(ncol=2)
Getting it to be the approximate height and width is an art. This is not even close but looks centered.

Avi
On Mon, Jan 3, 2022 at 2:41 PM Avi Gross <avi.e...@gmail.com> wrote:
David,
Thanks for your question as it made me think and search for packages and options that might do what you want. Oddly, centering is not something I see the packages caring about! And, of course, sometimes you can get what you want by thinking outside the box. I note that if you are putting your graphs into a program that allows tables and centering, such as WORD or EXCEL, it becomes fairly easy to make an (invisible border?) table with the number of rows/columns you need and place images where you want and align some to be centered, horizontally and/or vertically within their cell. The sizes of the images as saved would remain fixed.
But if you want to remain within a package like patchwork, the documentation does suggest possibilities to get what you want albeit you might need to center it yourself. I am looking at this page, for example:
https://patchwork.data-imaginist.com/articles/guides/layout.html
There seem to be ways to ask it for a component to remain fixed and not be stretched. There is a method allowing inset_element() to place an image overlapping or within an image and I wonder if it could also be used to place it below the current row into an empty row and carefully offset to be in the middle.
The next clip indicates you can:
Further, inset_element() allows you to place the inset below the previous plot, should you choose to, and controlling clipping and tagging in the same way as wrap_elements().
p3 + inset_element(p1, left = 0.5, bottom = 0, right = 1, top = 0.5,
on_top = FALSE, align_to = 'full')
And note you can set heights and widths in some of the supplied functions to be the same for all as in:
plot_layout(widths=c(2,1))
I have to admit that what you want is fairly basic and you wonder why it is not already touted as a built-in feature somewhere. People do like having things centered. What I have done in the past when the bottom row was not full is to play various games to fill it somewhat. This can include putting in an image of the author, putting in (large) text with some useful or useless phrases perhaps about the problem or methods used or even move something like the guides into that empty slot.
Good Luck with finding a solution that works for you.
Avi
On Mon, Jan 3, 2022 at 7:03 AM David Kaplan <cubsf...@gmail.com> wrote:
Actually, I found that this works, though I would like to make the bottom plot in the same width and height as the others.
(ridge | laplace) /
(horseshoe | FinnHorseshoe) /
(plot_spacer() | spikeSlab | plot_spacer())
On Sunday, January 2, 2022 at 9:08:06 AM UTC-6 David Kaplan wrote:
Greetings all,
Below you'll see a series of plots. I would like the last plot to be centered below the plots in the second row but of the same height and width.
To view this discussion on the web visit https://groups.google.com/d/msgid/ggplot2/CABaFrRaRHgHUYeyq4OGs2o4JRpsvg8wMDx2ovGRWJ-mYepVXFA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ggplot2/CA%2BZT93OLmcj862zK17wRpzLxgjJCgT-ZonM2S%2BsH0-G_H_hoig%40mail.gmail.com.
