Fix code for 3d plot

data <- tomerdata

Add a new column with color

mycolors <- c('royalblue1', 'darkcyan', 'oldlace')
data$color <- mycolors[ as.numeric(data$Home) ]

Plot

plot3d(
x=data$Home.Length, y=data$Age.Width, z=data$Average_Grade.Length,
col = data$color,
type = 's',
radius = .1,
xlab="Home Length", ylab="Age Width", zlab="Average_Grade Length")
rglwidget()

htmlwidgets::saveWidget(rglwidget(width = 520, height = 520),
file = "HtmlWidget/3dscatter.html",
libdir = "libs",
selfcontained = FALSE
)

like you guys can see thats the code that i am trying to use to make 3d plot like this one:

but unfortunately all i got is wired shape that
when i click on the screen its move and doing wired shapes..
i dont know how to fix that
and i am looking for help.
thank you guys and have a good evening

code seems fine to me, i tested on iris dataset.
Is there something odd about your data ?
if you have skewed data / a strong outlier, then it could well make all the points invisible in a viewed out wireframe box; I guess my advice is know your data, and look for outliers...

btw the console with the strange shape look like that
like i had said when i hold my left mouse clicker on this console and start to move this shape changes

Hello.
Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.

Share some representative data that will enable your code to run and show the problematic behaviour.

You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.

Reprex Guide

i changed my dataBase right now to nycflights13, this data is available to everyone.
the code that i used for this plot is:

data <- flights

# Add a new column with color
mycolors <- c('royalblue1', 'darkcyan', 'oldlace')
data$color <- mycolors[ as.numeric(data$year) ]

# Plot
plot3d( 
  x=data$`distance.Length`, y=data$`distance.Width`, z=data$`day.Length`, 
  col = data$color, 
  type = 's', 
  radius = .1,
  xlab="distance Length", ylab="distance Width", zlab="day Length")
rglwidget()

htmlwidgets::saveWidget(rglwidget(width = 520, height = 520), 
                        file = "HtmlWidget/3dscatter.html",
                        libdir = "libs",
                        selfcontained = FALSE
)

i hope you can help me understand what i am doing wrong.
thank you for your answers.

the variables distance.Length etc to plot3d are not in data$ ...
p.s. the flight data is huge, trying to plot so many elements will likely take a long time on your computer

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.