How can I change the labels in the UpSet plot?
bagcik1lumc opened this issue ยท 10 comments
How can I change the labels "Set size" and "Intersection size" into something custom?
upset(data = head(file, 100), intersect = colnames(file),
name="",
width_ratio = 0.125,
ylab="",) +
labs(title = "",
caption = "")
I am going to close this one as answered. Thanks for trying complex-upset!
Last, how can I remove the x-axis ticks on the left bottom plot, the y-axis ticks on the bar plot and show percentages on the left bottom plot? This concerns upset_set_size() I believe.
There is an example on modifying ticks under https://krassowski.github.io/complex-upset/articles/Examples_R.html#rotate-labels
As for percentages on set sizes, see below:
upset(
movies, genres, width_ratio=0.5, max_size=100, min_size=15, wrap=TRUE,
set_sizes=(
upset_set_size(
mapping=aes(y=..count../max(..count..)),
)
+ scale_y_reverse(labels=scales::percent_format())
+ ylab('Size relative to the largest')
)
)
Reopening as these examples should be added to the documentation.
I've seen the example, but it does not explain how to remove the y-ticks in the base_annotations. If I add theme(axis.ticks.y=element_blank()) it will remove the whole bar plot
upset(
head(M4_BinaryMatrix, 100),
colnames(M4_BinaryMatrix),
base_annotations = list('Intersection size'=intersection_size(text_mapping=aes(label=paste0(round(
!!get_size_mode('exclusive_intersection')/!!get_size_mode('inclusive_union') * 100
), '%')))
+ ylab("")
+ theme(axis.ticks.y=element_blank(), plot.background=element_rect(fill='#E5D3B3'))),
name = "",
annotations = list(),
themes = upset_themes,
stripes = upset_stripes(),
labeller = identity,
height_ratio = 0.5,
width_ratio = 0.3,
wrap = FALSE,
set_sizes=(
upset_set_size(
mapping=aes(y=..count../max(..count..)),
)
+ scale_y_reverse(labels=scales::percent_format())
+ ylab("")
+ theme(axis.text.x = element_blank())
),
mode = "distinct",
queries = list(),
guides = NULL,
encode_sets = TRUE,
matrix = intersection_matrix(),
n_intersections=5
) +
labs(title = "",
caption = "")
Just swap ..count..
in the 4.4 Display counts example with the formula of choice for percentage, e.g. ..count../max(..count..)
.