timelyportfolio/svgPanZoom

linetype="blank" is causing an error in stat_density2d

Closed this issue · 8 comments

Awesome package! One difficulty I'm having is that when I make my ggplot with a stat_density2d layer, svgPanZoom throws and error if I set linetype to blank.

example code:
Works

p <- ggplot() + geom_point(data=data.frame(faithful),aes(x=eruptions,y=waiting)) + stat_density2d(data=data.frame(faithful),aes(x=eruptions,y=waiting, alpha =..level..),geom="polygon") + scale_alpha_continuous(range=c(0.05,0.2))
svgPanZoom(p)

Doesn't Work

p <- ggplot() + geom_point(data=data.frame(faithful),aes(x=eruptions,y=waiting)) + stat_density2d(data=data.frame(faithful),aes(x=eruptions,y=waiting, alpha =..level..),linetype="blank",geom="polygon") + scale_alpha_continuous(range=c(0.05,0.2))
svgPanZoom(p)
Error in as.hexmode(strsplit(lty, "")[[1]]) :
'x' cannot be coerced to class "hexmode"

Delighted to hear that you are using. While gridSVG produces cleaner/better SVG, it does not always succesfully render. One thing you can try is to use the dev.svg method. Here is how to do it. SVGAnnotation makes it a little easier but is not completely required. Let me know if this does not work. One issue I know will come up is if you have multiple of these on one page.

library(SVGAnnotation)
library(svgPanZoom)
library(ggplot2)

p <- ggplot() + geom_point(data=data.frame(faithful),aes(x=eruptions,y=waiting)) + stat_density2d(data=data.frame(faithful),aes(x=eruptions,y=waiting, alpha =..level..),linetype="blank",geom="polygon") + scale_alpha_continuous(range=c(0.05,0.2))
svgPanZoom(svgPlot(print(p),height = 10, width = 14))

Hmm, the code you gave me works great, but it looks like I'm getting some
weird duplication/cutting off of my image with different data. I'm only
doing one plot, but I do have multiple groups in my stat_density2d with my
actual data. Does this cause the issue you're thinking of?

I've got print screens of being zoomed in at varying levels. The
stat_density2d seems to be correct when zooming, but the ggimage I'm
plotting on gets screwed up.

[image: Inline image 1][image: Inline image 2][image: Inline image 3]

On Fri, Feb 27, 2015 at 2:18 PM, timelyportfolio notifications@github.com
wrote:

Delighted to hear that you are using. While gridSVG produces
cleaner/better SVG, it does not always succesfully render. One thing you
can try is to use the dev.svg method. Here is how to do it. SVGAnnotation
makes it a little easier but is not completely required. Let me know if
this does not work. One issue I know will come up is if you have multiple
of these on one page.

library(SVGAnnotation)
library(svgPanZoom)
p <- ggplot() + geom_point(data=data.frame(faithful),aes(x=eruptions,y=waiting)) + stat_density2d(data=data.frame(faithful),aes(x=eruptions,y=waiting, alpha =..level..),linetype="blan
k",geom="polygon") + scale_alpha_continuous(range=c(0.05,0.2))
svgPanZoom(svgPlot(p,height = 10, width = 14))


Reply to this email directly or view it on GitHub
#2 (comment)
.

For some reason, the screenshots are not showing up on my machine. The expected problem will come with text in the SVG caused by conflicting defs ids.

Hmm, can you see them now?

On Fri, Feb 27, 2015 at 3:20 PM, timelyportfolio notifications@github.com
wrote:

For some reason, the screenshots are not showing up on my machine. The
expected problem will come with text in the SVG caused by conflicting defs
ids.


Reply to this email directly or view it on GitHub
#2 (comment)
.

I still don't see but could be in my end. Let me play with it a bit and see if I can reproduce.

@ghotson, I think the issue might be with email. To get pics to show up in Github issues, you'll need to copy/paste into the online editor. Could you try that, or upload to something like imgur and send the link? Thanks.

Sure! Here's what happened when I zoomed in. Let me know if you can't reproduce it, and I can try looking into it further.

Ooh, I just tried it out in my browser instead of R studio's built in viewer, and it works without a hitch. I'll just be developing in my browser instead from now on.

Thanks again!