Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
BurgeKhalifa
New Member

Question about an UpSet plot for an R Custom Visual

I was wondering if anyone could help regarding the production of an UpSet plot for an R Custom Visual in Power BI. The code I have written produces the correct graph when run in R open but when I produce the RVisualHtml (after editing the format to get rid of the production of the data frame) it does not produce the desired graph. For some reason, it is ignoring the "axis_combmatrix()" and just producing an ordinary bar graph. I have posted the code and can respond to any queries you have but any help regarding the issue would be greatly appreciated.

 

Here is a link showing what I am talking about: https://imgur.com/a/9srj326 

 

Code:

library(ggplot2)

library(tidyverse)

library(ggupset)

library(RColorBrewer)

library(extrafont)

 

df <- structure(list(

id = 1:25,

"a" = c(

0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L,

0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L

),

"b" = c(

0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L,

1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L

),

"c" = c(

1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L,

0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L

),

"d" = c(

0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,

0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L

),

"e" = c(

0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,

0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L

),

"f" = c(

0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L,

1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L

),

"g" = c(

0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,

0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L

)

),

row.names = c(NA, -25L), spec = structure(list(

cols = list(

id = structure(list(),

class = c("collector_integer", "collector")

),

"a" = structure(list(), class = c("collector_integer", "collector")),

"b" = structure(list(), class = c("collector_integer", "collector")),

"c" = structure(list(), class = c("collector_integer", "collector")),

"d" = structure(list(), class = c("collector_integer", "collector")),

"e" = structure(list(), class = c("collector_integer", "collector")),

"f" = structure(list(), class = c("collector_integer", "collector")),

"g" = structure(list(), class = c("collector_integer", "collector"))

),

default = structure(list(), class = c("collector_guess", "collector"))

),

class = "col_spec"

), class = "data.frame"

)

 

tidy_df <- df %>%

gather(measure, value, 2:8) %>%

filter(value != 0) %>%

group_by(id) %>%

summarize(Connections = paste(sort(measure), collapse = " & "))

 

ggplot(tidy_df, aes(x = reorder(Connections, Connections, function(x) -length(x)))) +

geom_bar(aes(fill = Connections), colour = "black", position = "stack") +

axis_combmatrix() +

labs(

title = "UpSet plot",

y = "count", x = "Connections", caption = Sys.Date()

) +

theme_bw() +

scale_fill_brewer(palette = "Paired") +

theme(text = element_text(size = 11, family = "Segoe UI"), plot.margin = margin(10, 10, 10, 50))

0 REPLIES 0

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.