# Free scales on facets should take coord_flip into account #95

Closed
opened this Issue Apr 29, 2010 · 5 comments

None yet

### 5 participants

Contributor
commented Apr 29, 2010
 Let's consider this data ``````d <- data.frame(x=1:5, y=c(runif(5), runif(5)+5), a=rep(c("foo","bar"), each=5)) `````` The scale for y should be free. Faceting along the horizontal makes it impossible since there should only be one y scale: ``````ggplot(d) + geom_point(aes(x=x, y=y)) + facet_grid(.~a, scales="free_y") `````` This makes sense but a warning would be welcome ("Warning: The y scale cannot be free in this faceting configuration") Now faceting along the vertical or switching the coordinates allows a free scale ``````ggplot(d) + geom_point(aes(x=x, y=y)) + facet_grid(a~., scales="free_y") ggplot(d) + geom_point(aes(x=y, y=x)) + facet_grid(.~a, scales="free_x") `````` But flipping the coordinate system does not, while there are now two different axes for y ``````ggplot(d) + geom_point(aes(x=x, y=y)) + facet_grid(.~a, scales="free_y") + coord_flip() `````` I would expect this last plot to look just like the previous one.
commented Nov 28, 2011
 Hi, I've also encountered this problem. I wanted to use free scales so that elements that appear only in one facet won't appear in the axes of another (using a discrete scale). I couldn't use the above workaround, as I wanted to use geom_bar, so I had to use geom_rect instead, and reverse the coordinates manually.
Member
commented Dec 2, 2011
 Free scales aren't going to be working with non-Cartesian coordinates systems for a long time :/
referenced this issue Dec 2, 2011
Closed

#### coord_flip and free scales don't work #45

commented Mar 21, 2013
 Just to clarify: coord_flip = non-Cartesian?
Member
commented Feb 24, 2014
 This sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette.
closed this Feb 24, 2014
 I guess this is basically the same bug as the one that doesn't allow `scales=free_y` to play nicely with `scale_y_log10()`. Backreferencing other related bugs: #673 #675 #971 (maybe?) #601
added a commit to vlsi/ggplot2 that referenced this issue Sep 16, 2016
 vlsi `Approach facet_grid(scale="free") + coord_flip issue` ```The idea is to swap panel\$layout\$SCALE_X and panel\$layout\$SCALE_Y right after train_layout The thing is facet_grid tries to keep the same ranges for all columns and rows, however it does not know if the axes will be flipped, so when flip occurs the previously chosen set of facets no longer applies. The fix is to flip SCALE_X and SCALE_Y set of facets, so the ranges are properly computed Fixes #1492, #1470, #1393, #95``` `2b620ed`
referenced this issue Sep 16, 2016
Closed

#### Approach facet_grid(scale="free") + coord_flip issue #1756

added a commit to vlsi/ggplot2 that referenced this issue Sep 16, 2016
 vlsi `Approach facet_grid(scale="free") + coord_flip issue` ```The idea is to swap panel\$layout\$SCALE_X and panel\$layout\$SCALE_Y right after train_layout The thing is facet_grid tries to keep the same ranges for all columns and rows, however it does not know if the axes will be flipped, so when flip occurs the previously chosen set of facets no longer applies. The fix is to flip SCALE_X and SCALE_Y set of facets, so the ranges are properly computed Fixes #1492, #1470, #1393, #95``` `a27e1e2`