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

Size legend in plot_poppr_msn does not scale well with large nodes #186

Open
4 of 5 tasks
Neato-Nick opened this issue May 15, 2018 · 10 comments
Open
4 of 5 tasks

Size legend in plot_poppr_msn does not scale well with large nodes #186

Neato-Nick opened this issue May 15, 2018 · 10 comments

Comments

@Neato-Nick
Copy link

Neato-Nick commented May 15, 2018

Please place an "x" in all the boxes that apply

  • I have the most recent version of poppr and R
  • I have found a bug
  • I want to request a new feature

Please include a brief description of the problem with a code example:

I have an MSN with MLGs containing many individuals. I'd like to create a legend for node sizes in my MSN using the size.leg option. I've noticed that with my largest MLG, the circle is cut off by the edge of the plot space. I've toyed around with different values for parameters of the make_circle_legend internal function(xspace, x), but I can't get it quite right. I can recreate this issue by scaling up the circle size for an example dataset with fewer MLG's.

data(partial_clone)
pcmsn <- bruvo.msn(partial_clone, replen = rep(1, 10))
plot_poppr_msn(partial_clone, pcmsn, palette = spectral, inds = 9, pos = 5, nodescale = 100)

Let me know if you have any plans to fix this, or workarounds to suggest for me.

Thanks!

Update: Here's a reprex

library(poppr)
#> Loading required package: adegenet
#> Loading required package: ade4
#> 
#>    /// adegenet 2.1.1 is loaded ////////////
#> 
#>    > overview: '?adegenet'
#>    > tutorials/doc/questions: 'adegenetWeb()' 
#>    > bug reports/feature requests: adegenetIssues()
#> This is poppr version 2.7.1.99.79. To get started, type package?poppr
#> OMP parallel support: available
#> 
#> This version of poppr is under development.
#> If you find any bugs, please report them at https://github.com/grunwaldlab/poppr/issues
data(partial_clone)
pcmsn <- bruvo.msn(partial_clone, replen = rep(1, 10), showplot = FALSE)
plot_poppr_msn(partial_clone, pcmsn, nodescale = 100)


@zkamvar
Copy link
Member

zkamvar commented May 15, 2018

Hi Nick,

This particular legend is a bit of a pain to work with. At the moment, I'm not quite sure exactly HOW I would go about addressing the issue, so I'll keep this open for the time being.

In the meantime I have two suggestions:

  1. Decrease the nodescale option to 1 or even below 1.
  2. The circles are actually there, but they need to be nudged with an SVG editor like inkscape.

@Neato-Nick
Copy link
Author

Thanks for the response Zhian. Both of those workarounds sounds like good options. Didn't realise the elements were saved in that way if I save it as an SVG.

The link you sent me was very descriptive of the issue - many thanks!

@Neato-Nick
Copy link
Author

Update: It doesn't actually look like the full size of the circle is retained, even in the SVG. See the screenshots at the bottom. I'll use your suggestion #1 for now
image
image

@zkamvar
Copy link
Member

zkamvar commented May 21, 2018 via email

@Neato-Nick
Copy link
Author

Neato-Nick commented Jun 1, 2018

Good idea and thanks for the links. I was able to ungroup the layers, but it didn't resolve the issue

image

image

@zkamvar
Copy link
Member

zkamvar commented Jun 1, 2018 via email

@Neato-Nick
Copy link
Author

Woo more suggestions! Thanks for consistently writing back so fast. For people following along:

  1. When I scale the smaller circle up to the larger circle, the line width scales linear along with the radius of the circle. Makes sense, but I didn't think about it when I first tried it either. Maybe I can scale it up and then specify linewidth=1 posthoc? I'll try this

  2. Unfortunately the SVG saves each pie not as a circle, but as individual wedges. So I could manually construct the legend using the correct-sized nodes, but I would need to copy and paste all the wedges, then draw a new (white) circle in a layer on top of it to hide the lines of the wedges. Or maybe: select wedges -> group -> object fill white -> object stroke black. These might work!

On poppr side, I'm sure you thought of this, but would it work to construct the plot as a grid? If the MSN, population legend, and size legend were all in different parts of grid layout, you might be able to adjust the placement of the size legend within its part of the grid. Or maybe even just giving it its own section of the grid would solve the problem and it would be placed correctly without further manual adjustment. I'm not incredibly familiar with grid so I'm not super confident in this idea.

@zkamvar
Copy link
Member

zkamvar commented Jun 1, 2018

When I scale the smaller circle up to the larger circle, the line width scales linear along with the radius of the circle. Makes sense, but I didn't think about it when I first tried it either. Maybe I can scale it up and then specify linewidth=1 posthoc? I'll try this
Unfortunately the SVG saves each pie not as a circle, but as individual wedges. So I could manually construct the legend using the correct-sized nodes, but I would need to copy and paste all the wedges, then draw a new (white) circle in a layer on top of it to hide the lines of the wedges. Or maybe: select wedges -> group -> object fill white -> object stroke black. These might work!

I think both of these are solved using inkscape's "paste style" using ctrl+shift+v. Additionally, there is also a menu item that allows you to past just the size of an object/group.

@zkamvar
Copy link
Member

zkamvar commented Jun 1, 2018

On poppr side, I'm sure you thought of this, but would it work to construct the plot as a grid? If the MSN, population legend, and size legend were all in different parts of grid layout, you might be able to adjust the placement of the size legend within its part of the grid. Or maybe even just giving it its own section of the grid would solve the problem and it would be placed correctly without further manual adjustment. I'm not incredibly familiar with grid so I'm not super confident in this idea.

It hard.

@Neato-Nick
Copy link
Author

Hah - before I created this issue I forked the package and tried to just fix it myself.

It hard.

Can confirm.

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

No branches or pull requests

2 participants