plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.56k stars 627 forks source link

ggplotly on geom_tile: unnecessary warning produced #1670

Open alanocallaghan opened 4 years ago

alanocallaghan commented 4 years ago

When converting geom_tile with ggplotly, the warning 'heatmap' objects don't have these attributes: 'showlegend' is produced. I think this is just a mismatch in the internal API and should be an easy fix.

Seems to me that the issue arises here, where a value is assigned to it for all trace types. At least, if I comment this line out, the warning doesn't occur. https://github.com/ropensci/plotly/blob/e02a704d3743ef3dc59714af1b9fc6d3c248186e/R/ggplotly.R#L559

(link was out of date, I think the permalink is correct)

library("ggplot2")
library("reshape2")
library("plotly")
#> [startup msgs] 
mdf <- melt(as.matrix(mtcars))
g <- ggplot(mdf, aes(x = Var1, y = Var2, fill = value)) + geom_tile()
ggplotly(g)
#> Warning: 'heatmap' objects don't have these attributes: 'showlegend'
#> Valid attributes include:
#> 'type', 'visible', 'opacity', 'name', 'uid', 'ids', 'customdata', 'meta', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'z', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'text', 'hovertext', 'transpose', 'xtype', 'ytype', 'zsmooth', 'connectgaps', 'xgap', 'ygap', 'zhoverformat', 'hovertemplate', 'zauto', 'zmin', 'zmax', 'zmid', 'colorscale', 'autocolorscale', 'reversescale', 'showscale', 'colorbar', 'coloraxis', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'metasrc', 'hoverinfosrc', 'zsrc', 'xsrc', 'ysrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'

Cheers

talgalili commented 3 years ago

Hey @cpsievert - could you please help fix this?

wcwr commented 3 years ago

Also having this issue when converting geom_tilewith ggplotly:

Warning message:
'heatmap' objects don't have these attributes: 'mode'
Valid attributes include:
'type', 'visible', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'meta', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'z', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'xperiod', 'yperiod', 'xperiod0', 'yperiod0', 'xperiodalignment', 'yperiodalignment', 'text', 'hovertext', 'transpose', 'xtype', 'ytype', 'zsmooth', 'hoverongaps', 'connectgaps', 'xgap', 'ygap', 'zhoverformat', 'hovertemplate', 'showlegend', 'zauto', 'zmin', 'zmax', 'zmid', 'colorscale', 'autocolorscale', 'reversescale', 'showscale', 'colorbar', 'coloraxis', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'metasrc', 'hoverinfosrc', 'zsrc', 'xsrc', 'ysrc', 'textsrc', 'hovertextsrc', 'hovertemplatesrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'

EDIT:

resolved when I added linetype=1, and color="black" into my geom_hline of the tile plot.