Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help with script #184

Open
svedwards opened this issue Jan 21, 2025 · 0 comments
Open

help with script #184

svedwards opened this issue Jan 21, 2025 · 0 comments

Comments

@svedwards
Copy link

Hello -

Thanks for writing a really helpful script! I am trying to change the y-axis of the top panel in a facet_wrap but having a little trouble. I would like the y-axis of the top facet to go from 0 to 600 in increments of 200. My script and a few details on the data set are below. The current script simply returns the same set of facets as would be produced without the facetted_pos_scales arguments. I could get the middle facet to reverse the y-axis using the example you provided but can't quite figure out how to do my specific task.

subsetbar %>% ggplot(aes(x=total,y=n,fill=sum_type)) + geom_bar(stat = "identity",position=position_dodge(.7)) +
facet_wrap(sum_type ~.,ncol=1,scales = "free_y") +
scale_x_continuous(breaks = seq(0,70,4),labels = seq(0,70,4)) + theme_bw() +
xlab("total gene copies across haplotypes") + ylab("number of genes") +
theme(legend.text=element_text(size=20),legend.title = element_text(size = 20),strip.text.x = element_blank()) +
#facetted_pos_scales(y = list(NULL, scale_y_continuous(trans = "reverse")))
facetted_pos_scales(y = list(sum_type == "sumAC" ~ scale_y_continuous(breaks = seq(0,600,200))))

head(subsetbar)

A tibble: 6 × 3

Groups: sum_type [1]

sum_type total n

1 sumAC 0 15
2 sumAC 1 13
3 sumAC 2 10
4 sumAC 3 8
5 sumAC 4 6
6 sumAC 5 10

unique(subsetbar$sum_type)
[1] "sumAC" "sumAI" "sumAW"

example_facet_wrap.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant