我的代码使用R studio,在R中绘图,以及' parcoords'

时间:2017-09-13 20:37:46

标签: r rstudio plotly

我在R和' parcoords'中遇到麻烦。我尝试使用Persona定义的色阶进行绘图。角色的值为1到4,我希望每个数字都有自己的颜色。该图可以很好地缩放,但没有线代表每个变量的值。

以下是代码

options(viewer=NULL) 

p <- df %>% 
  plot_ly(type = 'parcoords', 
          line = list(color = ~Persona, 
                      colorscale = list(c(0,'red'),c(0.5,'green'),c(1,'blue'),c(1.5,'yellow'))) ,

          dimensions = list(
            list(range = c(15,55),
                 label = 'Rescuer Count', values = ~RescuerCount),
            list(range = c(15,50),
                 label = 'Rescuer Share', values = ~RescuerShare),
            list(range = c(5,95),
                 label = 'Avg Serviced Zip Codes', values = ~AvgServZips),
            list(range = c(10,925),
                 label = 'Avg Number of Rescues', values = ~ AAvgNumofRescues),
            list(range = c(310,16000),
                 label = 'Avg Rescuer Earnings', values = ~ AAEarnings),
            list(range = c(1,55),
                 label = 'Persona Share of Earnings', values = ~ EarnShare),
            list(range = c(30,95),
                 label = ' Login Percentage', values = ~ LoginPrct),
            list(range = c(7,95),
                 label = 'Prct of Login Days W/Offer', values = ~ PrctLoginDaysWO),
            list(range = c(1,5),
                 label = 'Avg Acceptance Rate', values = ~ AvgAcceptRate),
            list(range = c(150,1975),
                 label = 'Annualized Number of Offers', values = ~ ANumofOffers)
          )

)

print(p)

数据表在这里

Persona RescuerCount    RescuerShare    AvgServZips AAvgNumofRescues    AAEarnings  EarnShare   LoginPrct   PrctLoginDaysWO AvgAcceptRate   ANumofOffers
1   16  15  45  389 6706    27  71  91  30  1314
2   13  15  90  915 15805   51  91  94  47  1954
3   30  27  28  147 2429    18  55  86  22  679
4   51  46  6   20  319 4   34  75  13  152

resulting plot

请帮助

0 个答案:

没有答案