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

ggplotly export of tile geometry fails. #47

Closed
paulklemm opened this issue Jun 5, 2014 · 6 comments
Closed

ggplotly export of tile geometry fails. #47

paulklemm opened this issue Jun 5, 2014 · 6 comments

Comments

@paulklemm
Copy link

I don't know if I do something wrong or tiles are not yet supported by the exporter. When running

test <- data.frame(
  x = rep(c(1,3,6),2),
  y = rep(c(1,3), each = 3),
  w = rep(c(.5,2,1), 2),
  z = sample(rep(LETTERS[1:6])))

tilePlot <- ggplot(test, aes(x=x, y=y, fill = z)) + geom_tile(aes(width = w))
py$ggplotly(tilePlot);

I get the following Error:

Error in gg2list(gg) : No exportable traces
In addition: Warning message:
In layer2traces(L, df, misc) :
  Conversion not implemented for geom_tile (basic geom_tile), ignoring. Please open an issue with your example code at https://github.com/ropensci/plotly/issues
@xsaintmleux
Copy link

Thanks a lot for the example code! Your intuition was right: geom_tile is not supported yet. We'll let you know when it's done.

@paulklemm
Copy link
Author

👍 Thanks a lot!

@drewbo
Copy link

drewbo commented Jun 11, 2014

Any idea when this will be supported or any potential workarounds? I got the same error for geom_bin2d and stat_bind2d. Thanks for the updates

@msund
Copy link
Contributor

msund commented Jul 9, 2014

Hey @drewbo, we'd love to see your example code! One workaround could be trying out some of the native functions on Plotly? Our docs are here: plot.ly/r, and the latest for what you can do with ggplot2 support is at plot.ly/ggplot2.

@mkcor
Copy link
Contributor

mkcor commented Aug 21, 2014

Hello @powernap and thanks for your patience!

Right now in Plotly your z values cannot be of type character. I'll open an issue on Plotly's end so we can support this in the future.
I can suggest the following workaround:

library(plotly)

# Your initial data frame (up to randomization...)
test <- data.frame(
  x = rep(c(1,3,6),2),
  y = rep(c(1,3), each = 3),
  w = rep(c(.5,2,1), 2),
  z = sample(rep(LETTERS[1:6])))

# Define a function to map letter back to its index in the alphabet (sorry!)
let2ind <- function(x) which(LETTERS == as.character(x))

# Create new dimension z2
test$z2 <- sapply(test$z, let2ind)

# Plot tiles for z2 instead of z
tilePlot2 <- ggplot(test) + geom_tile(aes(x=x, y=y, fill=z2, width=w))
tilePlot2  # Looks different; play with color scales?

# Send to Plotly
py <- plotly()
py$ggplotly(tilePlot2)

As of yet, we don't support as much flexibility as ggplot2 in terms of controlling per-x width:
https://plot.ly/~mkcor/475
You can edit your plot further in the GUI using the Axes button (typically, X Axis: Category vs Linear). You can change the range and spacing for the x-axis. You can change the colorscale under Traces > Style.

Hope this helps!

@paulklemm
Copy link
Author

Hi @mkcor, thanks for this response! It looks good, I think I can work with this! Keep up the great work 👍

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

No branches or pull requests

5 participants