R:情节未完全加载 [英] R: Plot not Fully Loading
问题描述
我正在使用R编程语言.我正在尝试在此处遵循本教程:
有人知道为什么这两个图不同吗,我该如何解决?谢谢
本教程中使用的数据还有一个附加列 species_id
,该列是每个物种唯一的整数列.默认的 iris
数据集没有该数据集,因此您可以将作为因子的 Species
列转换为整数.
库(可打印)虹膜%>%plot_ly(type ='parcoords',line = list(color =〜as.integer(Species),colorscale = list(c(0,'red'),c(0.5,'green'),c(1,'blue')))),尺寸=列表(列表(范围= c(2,4.5),标签='Sepal宽度',值=〜Sepal.Width),list(范围= c(4,8),约束范围= c(5,6),标签='Sepal长度',值=〜Sepal.Length),列表(范围= c(0,2.5),标签='宽度'',值=〜宽度.),list(范围= c(1,7),标签='花瓣长度',值=〜花瓣长度)))
I am working the R programming language. I am trying to follow this tutorial over here: https://plotly.com/r/parallel-coordinates-plot/
I am trying to make a "parallel coordinate plot" of the famous iris data set.
Instead of loading the iris data set through the github link, I tried to use the built in iris data set that is available in R:
#load library
library(plotly)
#load data
data(iris)
df = iris
#make plot
fig <- df %>% plot_ly(type = 'parcoords', line = list(color = ~Species, colorscale = list(c(0,'red'),c(0.5,'green'),c(1,'blue'))), dimensions = list( list(range = c(2,4.5), label = 'Sepal Width', values = ~Sepal.Width), list(range = c(4,8), constraintrange = c(5,6), label = 'Sepal Length', values = ~Sepal.Length), list(range = c(0,2.5), label = 'Petal Width', values = ~Petal.Width), list(range = c(1,7), label = 'Petal Length', values = ~Petal.Length) ) )
#view plot
fig
However, this produces an incomplete plot:
Does anyone know why these two plots are different and how can I fix this? Thanks
The data used in the tutorial has an additional column species_id
which is an integer column unique for every species. The default iris
dataset does not have that so you can convert the Species
column which is factor to integer.
library(plotly)
iris %>% plot_ly(type = 'parcoords', line = list(color = ~as.integer(Species),
colorscale = list(c(0,'red'),c(0.5,'green'),c(1,'blue'))),
dimensions = list( list(range = c(2,4.5), label = 'Sepal Width', values = ~Sepal.Width),
list(range = c(4,8), constraintrange = c(5,6), label = 'Sepal Length', values = ~Sepal.Length),
list(range = c(0,2.5), label = 'Petal Width', values = ~Petal.Width),
list(range = c(1,7), label = 'Petal Length', values = ~Petal.Length) ) )
这篇关于R:情节未完全加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!