Legend is missing for type "mesh3d" unless some surface trace is added
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, r
- Domain
- data-visualization
Research direction
Start by reproducing the mesh3d examples in the issue and compare the behavior with the referenced plotly.js issue 2642 and pull request 4386. Trace how plotly.R passes mesh3d traces to plotly.js; done means a mesh3d trace shows its legend without requiring an added surface trace.
Written by the indexing model from the issue text.
Description
plotly.js added support for more trace legends but, for mesh3d, there is no legend below unless showlegend = TRUE for the mesh and a surface is added.
GH issue for more trace legends
merge for above
library(plotly)
library(rmarchingcubes)
R <- 2
f1 <- function(x, y, z){
x^2 + y^2 + z^2 - R^2
}
f2 <- function(x, y, z){
(x-2)^2 + (y-2)^2 + (z-2)^2 - R^2
}
g <- function(x, y, z) {
pmax(f1(x, y, z), f2(x, y, z))
}
n <- 100
x_ <- y_ <- z_ <- seq(-R, R, length.out = n)
Grid <- expand.grid(X = x_, Y = y_, Z = z_)
voxel <- with(Grid, array(g(X, Y, Z), dim = c(n, n, n)))
surf <- contour3d(voxel, level = 0, x_, y_, z_)
vertices <- surf$vertices
indices <- surf$triangles - 1L
plot_ly(
x = vertices[, 1], y = vertices[, 2], z = vertices[, 3],
i = indices[, 1], j = indices[, 2], k = indices[, 3],
type = "mesh3d",
name = "hello world",
showlegend = TRUE
) %>% layout(scene = list(aspectmode = "data"))
z <- c(
c(8.83,8.89,8.81,8.87,8.9,8.87),
c(8.89,8.94,8.85,8.94,8.96,8.92),
c(8.84,8.9,8.82,8.92,8.93,8.91),
c(8.79,8.85,8.79,8.9,8.94,8.92),
c(8.79,8.88,8.81,8.9,8.95,8.92),
c(8.8,8.82,8.78,8.91,8.94,8.92),
c(8.75,8.78,8.77,8.91,8.95,8.92),
c(8.8,8.8,8.77,8.91,8.95,8.94),
c(8.74,8.81,8.76,8.93,8.98,8.99),
c(8.89,8.99,8.92,9.1,9.13,9.11),
c(8.97,8.97,8.91,9.09,9.11,9.11),
c(9.04,9.08,9.05,9.25,9.28,9.27),
c(9,9.01,9,9.2,9.23,9.2),
c(8.99,8.99,8.98,9.18,9.2,9.19),
c(8.93,8.97,8.97,9.18,9.2,9.18)
)
dim(z) <- c(15,6)
plot_ly(
x = vertices[, 1], y = vertices[, 2], z = vertices[, 3],
i = indices[, 1], j = indices[, 2], k = indices[, 3],
type = "mesh3d",
name = "hello",
showscale = FALSE,
showlegend = TRUE
) %>%
plotly::layout(scene = list(aspectmode = "data")) %>%
add_surface(z = ~z, name = "placeholder")
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from plotly/plotly.R
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
save_image ErrorOpen
Difficulty 3/5 1-2 days Newbie friendliness 52/100
Similar issues
-
benchmark bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 Half a day Newbie friendliness 78/100
ThinkR-open/datadiff#59 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
epiforecasts/EpiNow2#1594 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
duckdb/duckdb-r#2773 · 1 comment ·
Maintainers usually reply within 1 day