Created
April 27, 2018 14:45
-
-
Save fbreitwieser/1f8840ea7a3699c812f8e4c3c8380741 to your computer and use it in GitHub Desktop.
common legend with cowplot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = read.delim("~/Accuracy_as_a_function_of_sketch_size_and_set_size.txt") | |
head(a) | |
a$rel_error = sqrt(a$Mean.squared.error) / a$Exact.size | |
a$p = factor(a$Sketch.size..log2.) | |
library(cowplot) | |
library(ggplot2) | |
plot1 = ggplot(a, aes(x=Exact.size, sqrt(Mean.squared.error) / Exact.size, | |
col=p)) + scale_y_continuous(labels = scales::percent) + | |
scale_x_log10( | |
breaks = scales::trans_breaks("log10", function(x) 10^x), | |
labels = scales::trans_format("log10", scales::math_format(10^.x)) | |
) + | |
geom_line() + geom_point() + cowplot::background_grid('y') + ggtitle("Mean sq error") | |
plot2 = ggplot(a, aes(x=Exact.size, Mean.bias / Exact.size, | |
col=p)) + scale_y_continuous(labels = scales::percent) + | |
scale_x_log10( | |
breaks = scales::trans_breaks("log10", function(x) 10^x), | |
labels = scales::trans_format("log10", scales::math_format(10^.x)) | |
) + | |
geom_line() + geom_point() + cowplot::background_grid('y') + ggtitle("Mean bias") | |
main = cowplot::plot_grid(plot1 + theme(legend.position = "none"), plot2 + theme(legend.position = "none")) | |
cowplot::plot_grid(main, cowplot::get_legend(plot1), ncol=2, rel_widths = c(1, .1)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment