Open ziyadsaeed opened 8 years ago
what then is the syntax to use a dataframe without converting it to a matrix Also Is there a way to tell it that the integer column x is the x label and integer column y is the y label and z values integer column z of the dataframe
I don't think it is currently possible to make a heatmap from a data frame. This will go on the todo list, but it isn't a super high priority right now.
PS. you can adds axis titles like so:
plot_ly(z = volcano, type = "heatmap") %>% layout(xaxis = list(title = "x"), yaxis = list(title = "y"))
for the time being this part of the heatmap documentation should be changed. Atleast it should mention that dataframe support is in the works
y (dataframe column, list, vector) Sets the y coordinates. x (dataframe column, list, vector) Sets the x coordinates. z (dataframe column, list, vector) Sets the z data.
@ziyadsaeed are you sure about your data.matrix solution? if I run your code, I get:
plot_ly(z = data.matrix(nba_players),
+ x = colnames(nba_players),
+ y = row.names(nba_players),
+ type = "heatmap")
Error: Variables must be length 1 or 50.
Problem variables: 'x'
Looks like the axes should have same length, otherwise it complains... I don't understand why though...
The figure reference documentation says
the df in the code above indicates a data frame The code below doesn't work
A solution is to use a data.matrix