Comments (4)
Hi there, can you post a reproducible example with, if your data are private, mocked up data or a standard dataset?
from ggh4x.
Super! thanks for your quick response. I uploaded the file and code for data visualization. ###
I failed with barplot, but succeed with boxplot.
##for barplot
pi_cf_blo <- ggbarplot(cytoflex_p1_blood,
x='Group',y='Statistic',nrow=1,
color = 'Group',fill = 'Group',alpha=.6,
#facet.by = c('cellCytokine'),
#facet.by = c('response','cellCytokine'),#'cellType','ICytokine'
palette = c(#'#868686FF',
"#CD534CFF",'#0073C2FF','#EFC000FF'),
add = c('mean_se','point'),
add.params = list(color='response',binwidth=1,
fill='response' ))+
scale_color_manual(values = c("High IL-6" = "black",
"Low IL-6" = 'gray'))+
ggh4x::facet_grid2(response ~ cellType + ICytokine,#Type, # cellCytokine, #
scales = 'free_y')+
scale_y_continuous(labels = scales::label_scientific(digits = 2))+
stat_pvalue_manual(stat_pvalue,label = 'p.adj.signif',tip.length = 0,
remove.bracket = F,hide.ns = T,size=2,#,
step.increase = 0.02,label.size = 2)+
theme(legend.position = 'top',
strip.placement = "outside",
panel.border = element_rect(color = NA, fill=NA),
axis.line = element_line(colour = "black"),
legend.key.size = unit(.5,units = 'cm'),
axis.text.x = element_blank(),
axis.text.y = element_text(face = 'bold',size = 7),
axis.title.y = element_text(face = 'bold',size = 13),
axis.title.x = element_blank(),
#legend.text = element_text(face = 'bold',size = 14),
legend.text = element_text(face = 'bold',size = 12),
legend.title = element_blank(),
strip.text.y = element_text(size = 10,face = 'bold'),
strip.text.x = element_text(size = 7,face = 'bold'))+
labs(x='Group',y='Blood Internal cytokine MFI')
pi_cf_blo
##for boxplot
ggboxplot(cytoflex_p1_blood,
x='Group',y='Statistic',nrow=1,
color = 'Group',fill = 'Group',alpha=.6,
palette = c(#'#868686FF',
"#CD534CFF",'#0073C2FF','#EFC000FF'),
add = 'point',
add.params = list(color='response',binwidth=.2,#size=.5,
fill='response'))+
scale_color_manual(values = c("High IL-6" = "black",
"Low IL-6" = 'gray'))+
ggh4x::facet_grid2(response ~ cellType + ICytokine,
scales = 'free_y',
independent = 'y'#,nrow = 1
)+
#facet_wrap(vars(cellType,ICytokine), scales = 'free_y',nrow = 1)+
scale_y_continuous(labels = scales::label_scientific(digits = 2))+
stat_pvalue_manual(stat_pvalue,label = 'p.adj.signif',tip.length = 0,
remove.bracket = F,hide.ns = T,size=2,#,
step.increase = 0.02,label.size = 2)+
theme(legend.position = 'top',
axis.text.x = element_blank(),
axis.text.y = element_text(face = 'bold',size = 7),
axis.title.y = element_text(face = 'bold',size = 13),
axis.title.x = element_blank(),
#legend.text = element_text(face = 'bold',size = 14),
legend.text = element_text(face = 'bold',size = 12),
legend.title = element_blank(),
strip.text.y = element_text(size = 10,face = 'bold'),
strip.text.x = element_text(size = 7,face = 'bold'))+
labs(x='Group',y='Blood Internal cytokine MFI')
from ggh4x.
I can't reproduce either of these plots as there seems to be a response
variable missing.
In general, my advise for doing any sort of advanced plotting is to build plots from scratch instead of relying on wrappers like ggbarplot()
. You can go layer-by-layer and identify more easily when something is going wrong.
from ggh4x.
Thanks for your advice, my apologies for the delay. I have attached an updated CSV file, I still have no idea how to have 3 facets in ggbarplot, will try with scratch as you suggested.
240208_dt.csv
Anyhow, I tried to merged the 'cellType' and 'cytokines' into a single variable, and presented it within one facet.
ggbarplot(cytoflex_p1_blood,
x='Group',y='Statistic',nrow=1,
facet.by = c('response','Type'),
color = 'Group',fill = 'Group',alpha=.6,
palette = c(#'#868686FF',
"#CD534CFF",'#0073C2FF','#EFC000FF'),
add = c('mean_se','point'),#'point',#
add.params = list(color='response',
binwidth=.1,#size=.5,
fill='response' ))+
scale_color_manual(values = c("High IL-6" = "black",
"Low IL-6" = 'gray'))+
ggh4x::facet_grid2(response ~ Type, #cellType + ICytokine,
scales = 'free_y',
independent = 'y'#,nrow = 1
)+
scale_y_continuous(labels = scales::label_scientific(digits = 2))+
theme(legend.position = 'top',
strip.placement = "outside",
panel.border = element_rect(color = NA, fill=NA),
axis.line = element_line(colour = "black"),
legend.key.size = unit(.5,units = 'cm'),
axis.text.x = element_blank(),#element_text(face = 'bold',size = 8),
# angle = 90),
axis.text.y = element_text(face = 'bold',size = 5),
axis.title.y = element_text(face = 'bold',size = 13),
axis.title.x = element_blank(),
#legend.text = element_text(face = 'bold',size = 14),
legend.text = element_text(face = 'bold',size = 12),
legend.title = element_blank(),
strip.text.y = element_text(size = 10,face = 'bold'),
strip.text.x = element_text(size = 5,face = 'bold',
colour = 'black'))+
labs(x='Group',y='Blood Internal cytokine MFI')
from ggh4x.
Related Issues (20)
- Text aesthetics in nested facets not working HOT 2
- Cannot use `trans` after using `facetted_pos_scales` HOT 3
- Release ggh4x 0.2.7
- facet_nested have a different behaviour as compare to facet_grid when combining character and numeric HOT 2
- facet_wrap2 adding wrong x axis labels HOT 3
- Facet size = "variable" not working? HOT 2
- Release ggh4x 0.2.8
- Missing data prevents setting up secondary y-axis scale in help_sec_range and help_sec_max HOT 1
- Ggplotly will move x-axis back to default position HOT 1
- Add tag_facet function? HOT 5
- Error when facetting and using `ggtext` HOT 3
- geom_rectmargin won't work bug with fill_alpha HOT 3
- ggtext::element_markdown not working with ggh4x_0.2.8 HOT 3
- Remove x-axis labels with independent = "x" if they are identical HOT 4
- Add compatibility with ggtext::element_markdown() HOT 1
- Error in check_object(cols, is_quosures, "a {.fn vars} specification" HOT 3
- facet_grid with remove_labels removes labels but leaves the space between the panels HOT 2
- `guide_stringlegend()` throws `Error in get_layer_key(...) : argument "data" is missing, no default` HOT 4
- S3 guide system deprecated in ggplot2 3.5.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ggh4x.