Skip to content

single point scatter3d traces fail in R #415

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

Closed
cldougl opened this issue Jan 20, 2016 · 6 comments
Closed

single point scatter3d traces fail in R #415

cldougl opened this issue Jan 20, 2016 · 6 comments

Comments

@cldougl
Copy link
Member

cldougl commented Jan 20, 2016

library(plotly)
p<-plot_ly(
  x = 1,
  y = 1,
  z = 1,
  type = "scatter3d", 
  mode = "markers")
p

plotly_POST(p)

@etpinard
Copy link

@cldougl really?

That shouldn't work. x, y, and z need to be arrays unless plotly_POST does something fancy.

@cpsievert
Copy link
Collaborator

@etpinard yea, I forgot about "z". This will be an easy fix.

> plotly:::get_boxed
function() {
  c("x", "y", "lat", "lon", "text")
}

@cpsievert
Copy link
Collaborator

@etpinard while were on the topic can you think of any other properties that should always be boxed, even if length 1?

@etpinard
Copy link

@cpsievert I guess all 'data_array' attributes as listed in the schema

e.g : https://github.com/plotly/plotly.js/blob/master/src/traces/scatter3d/attributes.js#L63

@cpsievert
Copy link
Collaborator

Thanks! Just for posterity:

$ cd plotly.js/src/traces
$ ag -B 1 'data_array'
box/attributes.js
20-    y: {
21:        valType: 'data_array',
27-    x: {
28:        valType: 'data_array',

choropleth/attributes.js
19-    locations: {
20:        valType: 'data_array',
27-    z: {
28:        valType: 'data_array',
31-    text: {
32:        valType: 'data_array',

choropleth/plot.js
43-
44:        // 'data_array' attributes

heatmap/attributes.js
18-    z: {
19:        valType: 'data_array',
28-    text: {
29:        valType: 'data_array',

histogram/attributes.js
20-    x: {
21:        valType: 'data_array',
26-    y: {
27:        valType: 'data_array',

histogram2d/attributes.js
18-    z: {
19:        valType: 'data_array',
23-        color: {
24:            valType: 'data_array',

mesh3d/attributes.js
17-    x: {
18:        valType: 'data_array',
21-    y: {
22:        valType: 'data_array',
25-    z: {
26:        valType: 'data_array',
30-    i: {
31:        valType: 'data_array',
34-    j: {
35:        valType: 'data_array',
38-    k: {
39:        valType: 'data_array',
68-    intensity: {
69:        valType: 'data_array',
82-    vertexcolor: {
83:        valType: 'data_array',  // FIXME: this should be a color array
90-    facecolor: {
91:        valType: 'data_array',

pie/attributes.js
19-    labels: {
20:        valType: 'data_array',
42-    values: {
43:        valType: 'data_array',
48-        colors: {
49:            valType: 'data_array',  // TODO 'color_array' ?
80-    text: {
81:        valType: 'data_array',

pie/layout_attributes.js
16-     */
17:    hiddenlabels: {valType: 'data_array'}

scatter/attributes.js
17-    x: {
18:        valType: 'data_array',
41-    y: {
42:        valType: 'data_array',
424-    r: {
425:        valType: 'data_array',
431-    t: {
432:        valType: 'data_array',

scatter3d/attributes.js
54-    x: {
55:        valType: 'data_array',
58-    y: {
59:        valType: 'data_array',
62-    z: {
63:        valType: 'data_array',

scattergeo/attributes.js
21-    lon: {
22:        valType: 'data_array',
25-    lat: {
26:        valType: 'data_array',
29-    locations: {
30:        valType: 'data_array',

surface/attributes.js
82-    z: {
83:        valType: 'data_array',
86-    x: {
87:        valType: 'data_array',
90-    y: {
91:        valType: 'data_array',
94-    text: {
95:        valType: 'data_array',

@federicou
Copy link

actually I'm encountering the same issue:

data.frame(c=c(rep("A",32),rep("B",2),rep("C",1)),x=runif(35),y=runif(35),z=runif(35)) %>%
plot_ly(x=x,y=y,z=z,color = c, type="scatter3d", mode="markers") -> p3

The plot displays only the 2 categories that have at least 2 points

cpsievert added a commit that referenced this issue Jan 25, 2016
more accurate 'boxing' of data_array properties. fixes #415
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

4 participants