How to scale ggplot annotation_custom layer with plotting device size?ggplot to png - automatically stretching imageHow to change facet labels?How to set limits for axes in ggplot2 R plots?ggplot: How to increase spacing between faceted plots?How to save a plot as image on the disk?How to change legend title in ggplotR version ggplot with extra table 3.2.1Adding a table to ggplot with gridExtra and annotation_custom() changes y-axis limitsR - gridExtra - some layer of ggplot() does not scalegridExtra panel plot with identical panel sizes in ggplotHow to plot two rasters with different extensions
What is the use case for non-breathable waterproof pants?
Why do testers need root cause analysis?
Are there any German nonsense poems (Jabberwocky)?
Why isn't Tyrion mentioned in 'A song of Ice and Fire'?
Ribbon Cable Cross Talk - Is there a fix after the fact?
Team has team lunch everyday, am I forced to go?
Flatten not working
Why did it take so long for Germany to allow electric scooters / e-rollers on the roads?
Can a UK national work as a paid shop assistant in the USA?
Are cells guaranteed to get at least one mitochondrion when they divide?
Unary Enumeration
ifconfig shows UP while ip link shows DOWN
Why did Drogon spare this character?
Who wrote “A writer only begins a book. A reader finishes it.”?
Is it safe to redirect stdout and stderr to the same file without file descriptor copies?
Why did OJ Simpson's trial take 9 months?
Visual Block Mode edit with sequential number
Possibility of faking someone's public key
Are runways booked by airlines to land their planes?
What is Orcus doing with Mind Flayers in the art on the last page of Volo's Guide to Monsters?
How to deceive the MC
Is a world with one country feeding everyone possible?
How does the Earth's center produce heat?
Can a multiclassed Kensei monk/Swashbuckler rogue use an offhand finesse weapon to trigger Sneak Attack, without using a bonus action?
How to scale ggplot annotation_custom layer with plotting device size?
ggplot to png - automatically stretching imageHow to change facet labels?How to set limits for axes in ggplot2 R plots?ggplot: How to increase spacing between faceted plots?How to save a plot as image on the disk?How to change legend title in ggplotR version ggplot with extra table 3.2.1Adding a table to ggplot with gridExtra and annotation_custom() changes y-axis limitsR - gridExtra - some layer of ggplot() does not scalegridExtra panel plot with identical panel sizes in ggplotHow to plot two rasters with different extensions
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'd like to plot multiple ggplots that have annotation layers using plot_grid or a similar function and keep the relative size/position of the annotation layer the same when plotting. The following is an example:
# Generate scatter plot with ggplot.
library(ggplot2)
data <- data.frame(x = rnorm(1000),
y = rnorm(1000))
p1 <- ggplot(data, aes(x = x, y = y)) + geom_point()
# Build annotation table with gridExtra::tableGrob().
library(gridExtra)
mytable <- summary(data)
tab <- tableGrob(mytable, rows=NULL, theme=tt)
# Extract x and ylims for positioning table with ggplot_build().
xrange <- unlist(ggplot_build(p1)$layout$panel_params[[1]][1])
yrange <- unlist(ggplot_build(p1)$layout$panel_params[[1]][8])
xmin = min(xrange)
xmax = max(xrange)
xdelta = xmax-xmin
ymin = min(yrange)
ymax = max(yrange)
ydelta = ymax-ymin
# Add annotation table to plot.
p2 <- p1 + annotation_custom(tab, xmin = xmin-0.55*xdelta, xmax,
ymin = ymin+0.55*ydelta, ymax)
p2
# Generate figure with multiple plots using cowplot::plot_grid().
library(cowplot)
fig <- plot_grid(p2,p2,p2,p2, labels = "auto")
fig
Please help me keep the scale and position of the annotation layer the same in the final figure. Ideally, this could be done in the order of my example: make a plot with annotation, plot multiple plots, but I understand if this is not possible.
Edit.
Scaling the plotting device does not seem to fix the problem.
## Exploring changing the device size.
# I think the default device size is 7x7 inches.
png("default_size.png",width = 7, height = 7, res = 300, units = "in")
p2
dev.off()
# Plot2x
png("2x_size.png",width = 14, height = 14, res = 300, units = "in")
p2
dev.off()
# Plot3x
png("3x_size.png",width = 21, height = 21, res = 300, units = "in")
p2
dev.off()
r ggplot2 gridextra
|
show 1 more comment
I'd like to plot multiple ggplots that have annotation layers using plot_grid or a similar function and keep the relative size/position of the annotation layer the same when plotting. The following is an example:
# Generate scatter plot with ggplot.
library(ggplot2)
data <- data.frame(x = rnorm(1000),
y = rnorm(1000))
p1 <- ggplot(data, aes(x = x, y = y)) + geom_point()
# Build annotation table with gridExtra::tableGrob().
library(gridExtra)
mytable <- summary(data)
tab <- tableGrob(mytable, rows=NULL, theme=tt)
# Extract x and ylims for positioning table with ggplot_build().
xrange <- unlist(ggplot_build(p1)$layout$panel_params[[1]][1])
yrange <- unlist(ggplot_build(p1)$layout$panel_params[[1]][8])
xmin = min(xrange)
xmax = max(xrange)
xdelta = xmax-xmin
ymin = min(yrange)
ymax = max(yrange)
ydelta = ymax-ymin
# Add annotation table to plot.
p2 <- p1 + annotation_custom(tab, xmin = xmin-0.55*xdelta, xmax,
ymin = ymin+0.55*ydelta, ymax)
p2
# Generate figure with multiple plots using cowplot::plot_grid().
library(cowplot)
fig <- plot_grid(p2,p2,p2,p2, labels = "auto")
fig
Please help me keep the scale and position of the annotation layer the same in the final figure. Ideally, this could be done in the order of my example: make a plot with annotation, plot multiple plots, but I understand if this is not possible.
Edit.
Scaling the plotting device does not seem to fix the problem.
## Exploring changing the device size.
# I think the default device size is 7x7 inches.
png("default_size.png",width = 7, height = 7, res = 300, units = "in")
p2
dev.off()
# Plot2x
png("2x_size.png",width = 14, height = 14, res = 300, units = "in")
p2
dev.off()
# Plot3x
png("3x_size.png",width = 21, height = 21, res = 300, units = "in")
p2
dev.off()
r ggplot2 gridextra
Your question actually doesn't make sense to me. what the output looks like depends on the width and height that you provide to export function (I think you are working in RStudio and using GUI to export). Just increase the width and height by factor of 2 or whatever you desire.
– M-M
Mar 23 at 22:04
Frustrated because your comment that the question does not make sense is not productive. How can I revise to make the question more clear? However you may have pointed out the crux of the problem. As I illustrate in my edit, when changing the plotting device size the annotation layer does not seem to be scaled with the plot. I think I'm missing something fundamental, but looking for what this is.
– twb10
Mar 24 at 14:02
Searching for fixed annotated tables/text on ggplot regardless of scale/size, seems that your question is very much so legit. As I said, and provided the answer, using the right width and height can address the problem but that's rather a "hacky" solution. I am curious if there is a solution that would work for this problem and is not dependent of the plot size/setup.
– M-M
Mar 25 at 17:08
1
Look at this thread stackoverflow.com/questions/40461852/…
– M-M
Mar 25 at 21:30
1
Thanks for the ggsave solution. I have also been unable to find a better solution, but I think gtable may hold some solutions: cran.r-project.org/web/packages/gridExtra/vignettes/gtable.html.
– twb10
Mar 26 at 13:36
|
show 1 more comment
I'd like to plot multiple ggplots that have annotation layers using plot_grid or a similar function and keep the relative size/position of the annotation layer the same when plotting. The following is an example:
# Generate scatter plot with ggplot.
library(ggplot2)
data <- data.frame(x = rnorm(1000),
y = rnorm(1000))
p1 <- ggplot(data, aes(x = x, y = y)) + geom_point()
# Build annotation table with gridExtra::tableGrob().
library(gridExtra)
mytable <- summary(data)
tab <- tableGrob(mytable, rows=NULL, theme=tt)
# Extract x and ylims for positioning table with ggplot_build().
xrange <- unlist(ggplot_build(p1)$layout$panel_params[[1]][1])
yrange <- unlist(ggplot_build(p1)$layout$panel_params[[1]][8])
xmin = min(xrange)
xmax = max(xrange)
xdelta = xmax-xmin
ymin = min(yrange)
ymax = max(yrange)
ydelta = ymax-ymin
# Add annotation table to plot.
p2 <- p1 + annotation_custom(tab, xmin = xmin-0.55*xdelta, xmax,
ymin = ymin+0.55*ydelta, ymax)
p2
# Generate figure with multiple plots using cowplot::plot_grid().
library(cowplot)
fig <- plot_grid(p2,p2,p2,p2, labels = "auto")
fig
Please help me keep the scale and position of the annotation layer the same in the final figure. Ideally, this could be done in the order of my example: make a plot with annotation, plot multiple plots, but I understand if this is not possible.
Edit.
Scaling the plotting device does not seem to fix the problem.
## Exploring changing the device size.
# I think the default device size is 7x7 inches.
png("default_size.png",width = 7, height = 7, res = 300, units = "in")
p2
dev.off()
# Plot2x
png("2x_size.png",width = 14, height = 14, res = 300, units = "in")
p2
dev.off()
# Plot3x
png("3x_size.png",width = 21, height = 21, res = 300, units = "in")
p2
dev.off()
r ggplot2 gridextra
I'd like to plot multiple ggplots that have annotation layers using plot_grid or a similar function and keep the relative size/position of the annotation layer the same when plotting. The following is an example:
# Generate scatter plot with ggplot.
library(ggplot2)
data <- data.frame(x = rnorm(1000),
y = rnorm(1000))
p1 <- ggplot(data, aes(x = x, y = y)) + geom_point()
# Build annotation table with gridExtra::tableGrob().
library(gridExtra)
mytable <- summary(data)
tab <- tableGrob(mytable, rows=NULL, theme=tt)
# Extract x and ylims for positioning table with ggplot_build().
xrange <- unlist(ggplot_build(p1)$layout$panel_params[[1]][1])
yrange <- unlist(ggplot_build(p1)$layout$panel_params[[1]][8])
xmin = min(xrange)
xmax = max(xrange)
xdelta = xmax-xmin
ymin = min(yrange)
ymax = max(yrange)
ydelta = ymax-ymin
# Add annotation table to plot.
p2 <- p1 + annotation_custom(tab, xmin = xmin-0.55*xdelta, xmax,
ymin = ymin+0.55*ydelta, ymax)
p2
# Generate figure with multiple plots using cowplot::plot_grid().
library(cowplot)
fig <- plot_grid(p2,p2,p2,p2, labels = "auto")
fig
Please help me keep the scale and position of the annotation layer the same in the final figure. Ideally, this could be done in the order of my example: make a plot with annotation, plot multiple plots, but I understand if this is not possible.
Edit.
Scaling the plotting device does not seem to fix the problem.
## Exploring changing the device size.
# I think the default device size is 7x7 inches.
png("default_size.png",width = 7, height = 7, res = 300, units = "in")
p2
dev.off()
# Plot2x
png("2x_size.png",width = 14, height = 14, res = 300, units = "in")
p2
dev.off()
# Plot3x
png("3x_size.png",width = 21, height = 21, res = 300, units = "in")
p2
dev.off()
r ggplot2 gridextra
r ggplot2 gridextra
edited Mar 25 at 15:11
M-M
7,73262447
7,73262447
asked Mar 23 at 21:45
twb10twb10
11716
11716
Your question actually doesn't make sense to me. what the output looks like depends on the width and height that you provide to export function (I think you are working in RStudio and using GUI to export). Just increase the width and height by factor of 2 or whatever you desire.
– M-M
Mar 23 at 22:04
Frustrated because your comment that the question does not make sense is not productive. How can I revise to make the question more clear? However you may have pointed out the crux of the problem. As I illustrate in my edit, when changing the plotting device size the annotation layer does not seem to be scaled with the plot. I think I'm missing something fundamental, but looking for what this is.
– twb10
Mar 24 at 14:02
Searching for fixed annotated tables/text on ggplot regardless of scale/size, seems that your question is very much so legit. As I said, and provided the answer, using the right width and height can address the problem but that's rather a "hacky" solution. I am curious if there is a solution that would work for this problem and is not dependent of the plot size/setup.
– M-M
Mar 25 at 17:08
1
Look at this thread stackoverflow.com/questions/40461852/…
– M-M
Mar 25 at 21:30
1
Thanks for the ggsave solution. I have also been unable to find a better solution, but I think gtable may hold some solutions: cran.r-project.org/web/packages/gridExtra/vignettes/gtable.html.
– twb10
Mar 26 at 13:36
|
show 1 more comment
Your question actually doesn't make sense to me. what the output looks like depends on the width and height that you provide to export function (I think you are working in RStudio and using GUI to export). Just increase the width and height by factor of 2 or whatever you desire.
– M-M
Mar 23 at 22:04
Frustrated because your comment that the question does not make sense is not productive. How can I revise to make the question more clear? However you may have pointed out the crux of the problem. As I illustrate in my edit, when changing the plotting device size the annotation layer does not seem to be scaled with the plot. I think I'm missing something fundamental, but looking for what this is.
– twb10
Mar 24 at 14:02
Searching for fixed annotated tables/text on ggplot regardless of scale/size, seems that your question is very much so legit. As I said, and provided the answer, using the right width and height can address the problem but that's rather a "hacky" solution. I am curious if there is a solution that would work for this problem and is not dependent of the plot size/setup.
– M-M
Mar 25 at 17:08
1
Look at this thread stackoverflow.com/questions/40461852/…
– M-M
Mar 25 at 21:30
1
Thanks for the ggsave solution. I have also been unable to find a better solution, but I think gtable may hold some solutions: cran.r-project.org/web/packages/gridExtra/vignettes/gtable.html.
– twb10
Mar 26 at 13:36
Your question actually doesn't make sense to me. what the output looks like depends on the width and height that you provide to export function (I think you are working in RStudio and using GUI to export). Just increase the width and height by factor of 2 or whatever you desire.
– M-M
Mar 23 at 22:04
Your question actually doesn't make sense to me. what the output looks like depends on the width and height that you provide to export function (I think you are working in RStudio and using GUI to export). Just increase the width and height by factor of 2 or whatever you desire.
– M-M
Mar 23 at 22:04
Frustrated because your comment that the question does not make sense is not productive. How can I revise to make the question more clear? However you may have pointed out the crux of the problem. As I illustrate in my edit, when changing the plotting device size the annotation layer does not seem to be scaled with the plot. I think I'm missing something fundamental, but looking for what this is.
– twb10
Mar 24 at 14:02
Frustrated because your comment that the question does not make sense is not productive. How can I revise to make the question more clear? However you may have pointed out the crux of the problem. As I illustrate in my edit, when changing the plotting device size the annotation layer does not seem to be scaled with the plot. I think I'm missing something fundamental, but looking for what this is.
– twb10
Mar 24 at 14:02
Searching for fixed annotated tables/text on ggplot regardless of scale/size, seems that your question is very much so legit. As I said, and provided the answer, using the right width and height can address the problem but that's rather a "hacky" solution. I am curious if there is a solution that would work for this problem and is not dependent of the plot size/setup.
– M-M
Mar 25 at 17:08
Searching for fixed annotated tables/text on ggplot regardless of scale/size, seems that your question is very much so legit. As I said, and provided the answer, using the right width and height can address the problem but that's rather a "hacky" solution. I am curious if there is a solution that would work for this problem and is not dependent of the plot size/setup.
– M-M
Mar 25 at 17:08
1
1
Look at this thread stackoverflow.com/questions/40461852/…
– M-M
Mar 25 at 21:30
Look at this thread stackoverflow.com/questions/40461852/…
– M-M
Mar 25 at 21:30
1
1
Thanks for the ggsave solution. I have also been unable to find a better solution, but I think gtable may hold some solutions: cran.r-project.org/web/packages/gridExtra/vignettes/gtable.html.
– twb10
Mar 26 at 13:36
Thanks for the ggsave solution. I have also been unable to find a better solution, but I think gtable may hold some solutions: cran.r-project.org/web/packages/gridExtra/vignettes/gtable.html.
– twb10
Mar 26 at 13:36
|
show 1 more comment
1 Answer
1
active
oldest
votes
Using ggsave()
and defining appropriate width
and height
this worked for me;
library(ggplot2)
library(gridExtra)
set.seed(123) #make the result reproducible
#avoid using data as your dataframe name
mydf <- data.frame(x = rnorm(1000),
y = rnorm(1000))
plt <- ggplot(mydf, aes(x = x, y = y)) + geom_point()
mytable <- summary(mydf)
mytab <- tableGrob(mytable, rows=NULL) #theme = tt? tt is not defined!
xrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][1])
yrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][8])
xmin = min(xrange)
xmax = max(xrange)
xdelta = xmax-xmin
ymin = min(yrange)
ymax = max(yrange)
ydelta = ymax-ymin
tplt <- plt + annotation_custom(tab, xmin = xmin-0.55*xdelta, xmax,
ymin = ymin+0.55*ydelta, ymax)
mygrobs <- grid.arrange(tplt, tplt, tplt, tplt,
nrow = 2)
ggsave("filename.jpeg", plot = mygrobs,
scale = 1, width = 15, height = 10, units = "in",
dpi = 300)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318693%2fhow-to-scale-ggplot-annotation-custom-layer-with-plotting-device-size%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using ggsave()
and defining appropriate width
and height
this worked for me;
library(ggplot2)
library(gridExtra)
set.seed(123) #make the result reproducible
#avoid using data as your dataframe name
mydf <- data.frame(x = rnorm(1000),
y = rnorm(1000))
plt <- ggplot(mydf, aes(x = x, y = y)) + geom_point()
mytable <- summary(mydf)
mytab <- tableGrob(mytable, rows=NULL) #theme = tt? tt is not defined!
xrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][1])
yrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][8])
xmin = min(xrange)
xmax = max(xrange)
xdelta = xmax-xmin
ymin = min(yrange)
ymax = max(yrange)
ydelta = ymax-ymin
tplt <- plt + annotation_custom(tab, xmin = xmin-0.55*xdelta, xmax,
ymin = ymin+0.55*ydelta, ymax)
mygrobs <- grid.arrange(tplt, tplt, tplt, tplt,
nrow = 2)
ggsave("filename.jpeg", plot = mygrobs,
scale = 1, width = 15, height = 10, units = "in",
dpi = 300)
add a comment |
Using ggsave()
and defining appropriate width
and height
this worked for me;
library(ggplot2)
library(gridExtra)
set.seed(123) #make the result reproducible
#avoid using data as your dataframe name
mydf <- data.frame(x = rnorm(1000),
y = rnorm(1000))
plt <- ggplot(mydf, aes(x = x, y = y)) + geom_point()
mytable <- summary(mydf)
mytab <- tableGrob(mytable, rows=NULL) #theme = tt? tt is not defined!
xrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][1])
yrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][8])
xmin = min(xrange)
xmax = max(xrange)
xdelta = xmax-xmin
ymin = min(yrange)
ymax = max(yrange)
ydelta = ymax-ymin
tplt <- plt + annotation_custom(tab, xmin = xmin-0.55*xdelta, xmax,
ymin = ymin+0.55*ydelta, ymax)
mygrobs <- grid.arrange(tplt, tplt, tplt, tplt,
nrow = 2)
ggsave("filename.jpeg", plot = mygrobs,
scale = 1, width = 15, height = 10, units = "in",
dpi = 300)
add a comment |
Using ggsave()
and defining appropriate width
and height
this worked for me;
library(ggplot2)
library(gridExtra)
set.seed(123) #make the result reproducible
#avoid using data as your dataframe name
mydf <- data.frame(x = rnorm(1000),
y = rnorm(1000))
plt <- ggplot(mydf, aes(x = x, y = y)) + geom_point()
mytable <- summary(mydf)
mytab <- tableGrob(mytable, rows=NULL) #theme = tt? tt is not defined!
xrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][1])
yrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][8])
xmin = min(xrange)
xmax = max(xrange)
xdelta = xmax-xmin
ymin = min(yrange)
ymax = max(yrange)
ydelta = ymax-ymin
tplt <- plt + annotation_custom(tab, xmin = xmin-0.55*xdelta, xmax,
ymin = ymin+0.55*ydelta, ymax)
mygrobs <- grid.arrange(tplt, tplt, tplt, tplt,
nrow = 2)
ggsave("filename.jpeg", plot = mygrobs,
scale = 1, width = 15, height = 10, units = "in",
dpi = 300)
Using ggsave()
and defining appropriate width
and height
this worked for me;
library(ggplot2)
library(gridExtra)
set.seed(123) #make the result reproducible
#avoid using data as your dataframe name
mydf <- data.frame(x = rnorm(1000),
y = rnorm(1000))
plt <- ggplot(mydf, aes(x = x, y = y)) + geom_point()
mytable <- summary(mydf)
mytab <- tableGrob(mytable, rows=NULL) #theme = tt? tt is not defined!
xrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][1])
yrange <- unlist(ggplot_build(plt)$layout$panel_params[[1]][8])
xmin = min(xrange)
xmax = max(xrange)
xdelta = xmax-xmin
ymin = min(yrange)
ymax = max(yrange)
ydelta = ymax-ymin
tplt <- plt + annotation_custom(tab, xmin = xmin-0.55*xdelta, xmax,
ymin = ymin+0.55*ydelta, ymax)
mygrobs <- grid.arrange(tplt, tplt, tplt, tplt,
nrow = 2)
ggsave("filename.jpeg", plot = mygrobs,
scale = 1, width = 15, height = 10, units = "in",
dpi = 300)
edited Mar 25 at 15:52
answered Mar 25 at 14:17
M-MM-M
7,73262447
7,73262447
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318693%2fhow-to-scale-ggplot-annotation-custom-layer-with-plotting-device-size%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Your question actually doesn't make sense to me. what the output looks like depends on the width and height that you provide to export function (I think you are working in RStudio and using GUI to export). Just increase the width and height by factor of 2 or whatever you desire.
– M-M
Mar 23 at 22:04
Frustrated because your comment that the question does not make sense is not productive. How can I revise to make the question more clear? However you may have pointed out the crux of the problem. As I illustrate in my edit, when changing the plotting device size the annotation layer does not seem to be scaled with the plot. I think I'm missing something fundamental, but looking for what this is.
– twb10
Mar 24 at 14:02
Searching for fixed annotated tables/text on ggplot regardless of scale/size, seems that your question is very much so legit. As I said, and provided the answer, using the right width and height can address the problem but that's rather a "hacky" solution. I am curious if there is a solution that would work for this problem and is not dependent of the plot size/setup.
– M-M
Mar 25 at 17:08
1
Look at this thread stackoverflow.com/questions/40461852/…
– M-M
Mar 25 at 21:30
1
Thanks for the ggsave solution. I have also been unable to find a better solution, but I think gtable may hold some solutions: cran.r-project.org/web/packages/gridExtra/vignettes/gtable.html.
– twb10
Mar 26 at 13:36