- Since we will be plotting a 3D graph, we will add another variable Sepal.Width. The colors stay the same for the species.
plot_ly(iris,
x = ~Sepal.Length,
y = ~Sepal.Width,
z = ~Petal.Length,
color = ~Species,
colors = c("#8C1D40", "#1D8C39", "#1D398C"), # Custom colors
type = "scatter3d",
mode = "markers",
marker = list(size = 2)) %>%
layout(scene = list(xaxis = list(title = 'Sepal Length'),
yaxis = list(title = 'Sepal Width'),
zaxis = list(title = 'Petal Length')),
title = "3D View of Iris Measurements")