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

lables still overlapping #69

Open
carlotta-93 opened this issue Apr 20, 2020 · 5 comments
Open

lables still overlapping #69

carlotta-93 opened this issue Apr 20, 2020 · 5 comments
Labels

Comments

@carlotta-93
Copy link

carlotta-93 commented Apr 20, 2020

Hi,
Thank you for your amazing work, I am using your package a lot and find it very useful.
I have an issue with overlapping labels.
This is an example:

example_labels

As you can see the labels overlap with the percentages and counts.

I am using eulerr version 6.1.0 and this is the code I am using:

Screenshot 2020-04-20 at 11 08 04

Can you help ?

Thanks

@carlotta-93 carlotta-93 changed the title title and lables still overlapping lables still overlapping Apr 20, 2020
@JustGitting
Copy link

Hi @carlotta-93,

I had a similar problem, but I'm not sure it's related to your situation. I tried to reproduce your example, but cannot find any "Shulse" data sets.

Can you provide a minimal reproducible example?
I had to search for and install the Rknots package that provides the intersectionMatrix() function as I was not familiar with that function.

Also, I'd recommend not using images of code as it means anyone trying to help you needs to manually re-type the code.

@jolars jolars added the bug label Jun 26, 2020
@jolars
Copy link
Owner

jolars commented Jun 26, 2020

There is certainly work to be done regarding the label repulsion features of the package. The current code for this is imported from the ggrepel package, but I think it might be a good idea to consider something different or tinker with the settings.

A concomitant issue is that the extraneous white space around the figure is not used when moving around labels, which is related to how the aspect ratio is kept fixed at the moment.

I agree that there's lots to be done here, but at the moment I do not quite have the time to do so.

@carlotta-93
Copy link
Author

Hi @JustGitting, sorry for the late reply but I wanted to make this answer as complete as possible.

So, this is the code I am using, the function I defined:

makeEulerDiagram <- function(sets_list, color_palette, plot_name, plot_title, folder){
  plot_id <- as.symbol("plot_name")
  venset <- overLapper(sets_list, type="vennsets")
  plot_id <- plot(
    euler(intersectmatrix(venset), regionError = T),
    
    fills = list(fill=color_palette, alpha=0.8),
    
    edges = list(lwd=0.3),
    
    labels = list(fontfamily = "sans",
                  main.fontfamily = "sans",
                  cat.fontfamily = "sans",
                  fontsize=10,
                  padding=grid::unit(10, "mm")
    ),
    
    legend = list(fontsize=18),
    
    main = list(label=plot_title,
                fontsize=12
    ),
    
    percentages = list(fontsize=15
    ),
    
    quantities = list(type=c("counts","percent"), fontsize=15),
    
    adjust_labels = TRUE
    
  )
  print(plot_id)
  ggsave(plot_id, file=paste0(folder, plot_name, ".svg"), device = "svg", width = 30, height = 30, units="in")
  ggsave(plot_id, file=paste0(folder, plot_name, ".png"), device = "png", width = 30, height = 30, units="in")
}

This is how I call it:

makeEulerDiagram(list("this_is_list_A" = list_A, 
"this_is_list_B" = list_B), 
color_palette = c("#7d5a5a", "#f1d1d1"), 
plot_name = "pf2_de_genes_proteins", 
plot_title = paste0("intersection of list A and B"), 
folder = /path_to_folder/)

you can fin the two lists here: https://www.dropbox.com/s/1bjp5hrp7wml1ed/lists_github_example.xlsx?dl=0

And for now this is the output:
image

as you can see the problem is "solved" for this case, but I have many more examples, especially when intersecting more than 2 sets where the problem still persists.

For example here, it would be great if we managed to get ticks for example, going from the intersections to the labels that would be placed outside of the circles.
image

This is just a suggestion and for now I solved the problem with saving an svg file and modifying in photoshop.

Also, thank @jolars for getting back at us :)

@jw5
Copy link

jw5 commented Jan 14, 2021

I've found the ggrepl labeling function to be quite capable even with tight clusters.

Is it possible to provide a ggplot "plot" version?

I've pulled the ellipse definitions out and they plot fine with ggplot, but I couldn't find label locations and associated data.

@jolars
Copy link
Owner

jolars commented Jan 14, 2021

I've found the ggrepl labeling function to be quite capable even with tight clusters.

Is it possible to provide a ggplot "plot" version?

I am actually using the ggrepel code here, albeit not the latest revision. One of the problems is that I haven't been able to find a good way to use the whitespace on the left of the plot for moving labels (when there is whitespace).

I've pulled the ellipse definitions out and they plot fine with ggplot, but I couldn't find label locations and associated data.

Is this what you're looking for?

library(eulerr)

p <- plot(euler(c(A = 1, B = 2, "A&B" = 0.2)), quantities = TRUE)
p$data$centers
#>              x             y id labels quantities labels_par_id
#> A   -0.8141626 -3.167287e-02  1      A        1.0             1
#> B    0.6399415  3.100711e-02  2      B        2.0             2
#> A&B -0.1964353  1.638883e-05  3   <NA>        0.2            NA
#>     quantities_par_id
#> A                   1
#> B                   2
#> A&B                 3

Created on 2021-01-14 by the reprex package (v0.3.0)

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

No branches or pull requests

4 participants