Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Making Bigger Graphs when using facet_wrap()

Tags:

plot

r

knitr

I'm having some trouble visualizing some data in an R Markdown document. I'm attaching a picture for your reference.

I would like the graphs produced to be larger, and would expect the HTML page to allow for these graphs to be spread out, but they are all coming back "squished"

g <- ggplot(item_loc_metrics, aes(capc_ssp_ratio, avg_wk_bkrm_eoh)) + geom_point(color="firebrick")
g

I run this and it returns a nicely formatted graph: Graph of All data

This snippet of code works fine, but I would like to cut this same graph 60+ times based on the store I'm looking at. I've tried to to do that with this bit:

g2 <- ggplot(item_loc_metrics, aes(capc_ssp_ratio, avg_wk_bkrm_eoh)) + geom_point(color="firebrick") + facet_wrap(~CO_LOC_N, ncol=5, scales = "fixed", shrink = FALSE)
g2

I end up then getting something that looks like this:

Graphs of data by store

like image 548
Mike R Avatar asked Aug 08 '16 15:08

Mike R


People also ask

What is the difference between Facet_wrap and Facet_grid?

There are three types of faceting: facet_null() : a single plot, the default. facet_wrap() : “wraps” a 1d ribbon of panels into 2d. facet_grid() : produces a 2d grid of panels defined by variables which form the rows and columns.

What is graph faceting?

Faceting is the process that split the chart window in several small parts (a grid), and display a similar chart in each section. Each section usually shows the same graph for a specific group of the dataset. The result is usually called small multiple.

How do you plot a panel in R?

To create Multi Panel Plots in the R Language, we first divide the plot frame into the desired number of rows and columns and then fill those with desired plots. To divide the plot frame into the desired number of rows and columns, we use the par() function of the R Language.


1 Answers

To let this question have an answer, I add my two cents.

You can increase fig.height and fig.width(as suggested in the comment) and set ncol to one.

like image 180
Lerner Zhang Avatar answered Nov 04 '22 23:11

Lerner Zhang