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

Change axis text size and bar text size #178

Open
erikagucciardo opened this issue May 23, 2023 · 1 comment
Open

Change axis text size and bar text size #178

erikagucciardo opened this issue May 23, 2023 · 1 comment
Labels
help-request User requested help with the package

Comments

@erikagucciardo
Copy link

Hi,

I would like to change the axis text size and the size of the text on top of the bars, how to achieve that?

This is my current code; despite I set the size to be 4, the size does not change.

plot = ComplexUpset::upset(
  data = Joint.all,
  intersect = Workflows,
  min_size = 1,
  width_ratio = 0.1,
  stripes=c('white', '#F7F7F7'),
  set_sizes = (
    upset_set_size(
      geom = geom_bar(fill = "black")
    )
    + scale_y_continuous(limits = c(0,NA), 
                         breaks = c(0,1000,2000,3000),
                         labels = c("0","1k","2k","3k"))
  ),
  base_annotations = list(
    'Intersection size (>1500)'=(
      intersection_size(mapping = aes(fill = Patient),
                        text = list(size = 2))
      + coord_cartesian(ylim = c(2000, NA))
      + ylab('')
      + scale_fill_manual(values=c('1'='#006ba4',
                                   '2'='#ff800e',
                                   '3'='#ababab',
                                   '4'='#595959',
                                   '5'='#5f9ed1',
                                   '6'='#898989',
                                   '7'='#a2c8ec',
                                   '8'='#c85200',
                                   '9'='#ffbc79',
                                   '10'='#cfcfcf'))
    ),
    'Intersection size'=(
      intersection_size(mapping = aes(fill = Patient),
                        text = list(size = 2))
      + coord_cartesian(ylim = c(0, 50), expand = 0.000001)
      + scale_fill_manual(values=c('1'='#006ba4',
                                   '2'='#ff800e',
                                   '3'='#ababab',
                                   '4'='#595959',
                                   '5'='#5f9ed1',
                                   '6'='#898989',
                                   '7'='#a2c8ec',
                                   '8'='#c85200',
                                   '9'='#ffbc79',
                                   '10'='#cfcfcf'))
    )
  ),
  matrix = (
    intersection_matrix(
      geom = geom_point(
        size = 0.2
      ),
      segment = geom_segment(
        size = 0.2
      ))),
  themes = upset_modify_themes(
    list(
    intersections_matrix = list(
      theme(
        # hide intersections
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank(),
        # hide group title
        axis.title.y = element_blank(),
        axis.text.y = element_text(color = "red"),
        panel.grid = element_blank()
      )
    ),
    'Intersection size (>1500)' = list(
      theme_minimal(),
      theme(
        axis.text.x = element_blank(),
        axis.title.x = element_blank(),
        panel.grid = element_blank(),
        axis.text.y = element_text(size = 4, color = "red"),
        axis.line.y = element_line(colour = "black", size = 0.2344, lineend="round"),
        axis.ticks.y = element_line(colour = "black", size = 0.2344, lineend="round"),
        axis.ticks.length.y = unit(1, "pt"),
        legend.position = "none"
      )
    ),
    'Intersection size' = list(
      theme_minimal(),
      theme(
        axis.text.x = element_blank(),
        axis.title.x = element_blank(),
        panel.grid = element_blank(),
        axis.title.y = element_text(size = 4),
        axis.text.y = element_text(size = 4, color = "red"),
        axis.line = element_line(colour = "black", size = 0.2344, lineend="round"),
        axis.ticks.y = element_line(colour = "black", size = 0.2344, lineend="round"),
        axis.ticks.length.y = unit(1, "pt"),
        legend.text = element_text(colour = "black",size = 4),
        legend.justification = "top",
        legend.position = "none",
        legend.title = element_blank(),
        legend.key.size = unit(6,"pt"),
        legend.spacing.x = unit(1,"pt"),
        legend.background = element_blank(),
        legend.box.margin = margin(0,0,0,0),
        legend.margin = margin(c(0,0,0,0))
      )
    ),
    overall_sizes = list(
      theme(
        # hide groups
        axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(),
        axis.ticks.x = element_line(colour = "black", size = 0.2344, lineend="round"),
        axis.ticks.length.x = unit(1, "pt"),
        axis.title.x = element_text(size = 4),
        axis.text.x = element_text(size = 4, color = "black", angle = 90),
        panel.background = element_blank(),
        panel.grid = element_blank()
      )
    ),
    default=list(
      theme_minimal(),
      theme(
        axis.text.x=element_blank(),
        axis.title.x=element_blank()
      )
    )
  )
  )
  ,sort_intersections_by = "degree",
  guides = "keep"
) + patchwork::plot_layout(
  # 20/total for >1500, 100/total for <300, 50/total for intersection matrix, where total = 20+100+50
  heights=c(0.2, 1, 0.5)
)
plot
@erikagucciardo erikagucciardo added the help-request User requested help with the package label May 23, 2023
@erikagucciardo
Copy link
Author

I now see that it seems to rather be a problem with importing the PDF file to CorelDraw for editing...
It would still be great if you could check that the code is correct for what I am aiming to do :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-request User requested help with the package
Projects
None yet
Development

No branches or pull requests

1 participant