Discussion:
about facet_grid scales
Anil
2018-10-29 19:44:31 UTC
Permalink
Hi,

Is there a way to use different scales in each panel for facet_grid? I
know, scale="free". but it doesn't work. All y-axis is the same for each
panel.

Let's say I have five different panels (like A, B, C, D, E). In these
panels, for example, I have 8 columns in A panel, 12 columns in B, 5
columns in C, 8 in D, 8 in E.
Let's say, 3 columns have data but 5 columns have zero in A. 11 columns
have data, one is zero in B panel. And I want to show all columns for each
panel (even if zero) but panels have different scales.
And when I tried scales="free_x", only columns which have data, (not zero
ones) come in the figure.
--
--
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 ***@googlegroups.com
To unsubscribe: email ggplot2+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brandon Hurr
2018-10-30 00:59:06 UTC
Permalink
Anil,

Do you have an example dataset that is like your data or can you share your
data publicly?

Could you see the link in the bottom of this email about submitting a
reproducible example for how to do this best.

Thanks,
Brandon
Post by Anil
Hi,
Is there a way to use different scales in each panel for facet_grid? I
know, scale="free". but it doesn't work. All y-axis is the same for each
panel.
Let's say I have five different panels (like A, B, C, D, E). In these
panels, for example, I have 8 columns in A panel, 12 columns in B, 5
columns in C, 8 in D, 8 in E.
Let's say, 3 columns have data but 5 columns have zero in A. 11 columns
have data, one is zero in B panel. And I want to show all columns for each
panel (even if zero) but panels have different scales.
And when I tried scales="free_x", only columns which have data, (not zero
ones) come in the figure.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
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
For more options, visit https://groups.google.com/d/optout.
--
--
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 ***@googlegroups.com
To unsubscribe: email ggplot2+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
t***@uni-bremen.de
2018-10-30 08:22:12 UTC
Permalink
I am pretty sure, Anil refers to this problem:
https://stackoverflow.com/questions/30196143/bars-in-geom-bar-have-unwanted-different-widths-when-using-facet-wrap

Hope this helps, Tim
Post by Brandon Hurr
Anil,
Do you have an example dataset that is like your data or can you share your
data publicly?
Could you see the link in the bottom of this email about submitting a
reproducible example for how to do this best.
Thanks,
Brandon
Post by Anil
Hi,
Is there a way to use different scales in each panel for facet_grid? I
know, scale="free". but it doesn't work. All y-axis is the same for each
panel.
Let's say I have five different panels (like A, B, C, D, E). In these
panels, for example, I have 8 columns in A panel, 12 columns in B, 5
columns in C, 8 in D, 8 in E.
Let's say, 3 columns have data but 5 columns have zero in A. 11 columns
have data, one is zero in B panel. And I want to show all columns for each
panel (even if zero) but panels have different scales.
And when I tried scales="free_x", only columns which have data, (not zero
ones) come in the figure.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
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
For more options, visit https://groups.google.com/d/optout.
--
--
--
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 ***@googlegroups.com
To unsubscribe: email ggplot2+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Anil Aktas Samur
2018-10-30 14:38:08 UTC
Permalink
let's say my data is

dat1 <- data.frame(group=c("a", "a","a", "a", "a", "b", "b",
"b","b","b","b","b","c","c","c"),subgroup=c(paste0("R",
rep(1:5)),paste0("R", rep(1:7)),paste0("R", rep(1:3))),

value=c(5,6,0,8,2,3,4,5,2,4,7,0,3,4,0),pp=c("AT","BT","CT","AA","AT","TT","RT","CC","SE","DN","AA","MM","XT","QQ","HH"))
When I use following code :

pl <- ggplot(dat1, aes(y = as.character(pp), x = as.factor(subgroup))) +
geom_point( aes(size=as.numeric(value)))+ facet_grid(cols = vars(group))+
ylab("names") +xlab(" ")
pl
My figure is attached as "Denemeplot". But I want to add some cut off as
dat1 <- dat1[dat1$value >2 , ] and

pl <- ggplot(dat1, aes(y = as.character(pp), x = as.factor(subgroup))) +
geom_point( aes(size=as.numeric(value)))+ facet_grid(cols = vars(group),
scales="free", space="free")+
ylab("names") +xlab(" ")
pl
My figure is now as "denemeplot2"

But I want to all values with scales of each panel also even if zero. For
example in the second plot, the first panel has five value, so I want to
see all scale in the first panel, etc.

How can I make this plot?

Thanks,
Anil
Post by t***@uni-bremen.de
https://stackoverflow.com/questions/30196143/bars-in-geom-bar-have-unwanted-different-widths-when-using-facet-wrap
Hope this helps, Tim
Post by Brandon Hurr
Anil,
Do you have an example dataset that is like your data or can you share
your
Post by Brandon Hurr
data publicly?
Could you see the link in the bottom of this email about submitting a
reproducible example for how to do this best.
Thanks,
Brandon
Post by Anil
Hi,
Is there a way to use different scales in each panel for facet_grid? I
know, scale="free". but it doesn't work. All y-axis is the same for each
panel.
Let's say I have five different panels (like A, B, C, D, E). In these
panels, for example, I have 8 columns in A panel, 12 columns in B, 5
columns in C, 8 in D, 8 in E.
Let's say, 3 columns have data but 5 columns have zero in A. 11 columns
have data, one is zero in B panel. And I want to show all columns for
each
Post by Brandon Hurr
Post by Anil
panel (even if zero) but panels have different scales.
And when I tried scales="free_x", only columns which have data, (not
zero
Post by Brandon Hurr
Post by Anil
ones) come in the figure.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google
Groups
Post by Brandon Hurr
Post by Anil
"ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send
an
Post by Brandon Hurr
Post by Anil
For more options, visit https://groups.google.com/d/optout.
--
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
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
For more options, visit https://groups.google.com/d/optout.
--
--
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 ***@googlegroups.com
To unsubscribe: email ggplot2+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...