Black Lives Matter. Please consider donating to Black Girls Code today.

Cannot get plot lines to appear in a parallel coordinates plot

I’m having trouble with plotly in R and ‘parcoords’. I’m trying to plot using colorscale defined by Persona. Persona has values of 1 through 4 and I expect each number to have it’s own color. The plot scales fine but there are no lines representing the values for each variable.

Here is the code I’m using

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)

Here is the data frame

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

Any guidance is appreciated

1 Like

Me to I have the same problem. did you find the response

library(plotly)

df <- read.csv(“https://raw.githubusercontent.com/bcdunbar/datasets/master/parcoords_data.csv”)

p <- df %>%
plot_ly(width = 1500, height = 600) %>%
add_trace(type = ‘parcoords’,
line = list(color = ~colorVal,
colorscale = ‘Jet’,
showscale = TRUE,
reversescale = TRUE,
cmin = -4000,
cmax = -100),
dimensions = list(
list(range = c(~min(blockHeight),~max(blockHeight)),
constraintrange = c(100000,150000),
label = ‘Block Height’, values = ~blockHeight),
list(range = c(~min(blockWidth),~max(blockWidth)),
label = ‘Block Width’, values = ~blockWidth),
list(tickvals = c(0,0.5,1,2,3),
ticktext = c(‘A’,‘AB’,‘B’,‘Y’,‘Z’),
label = ‘Cyclinder Material’, values = ~cycMaterial),
list(range = c(-1,4),
tickvals = c(0,1,2,3),
label = ‘Block Material’, values = ~blockMaterial),
list(range = c(~min(totalWeight),~max(totalWeight)),
visible = TRUE,
label = ‘Total Weight’, values = ~totalWeight),
list(range = c(~min(assemblyPW),~max(assemblyPW)),
label = ‘Assembly Penalty Weight’, values = ~assemblyPW),
list(range = c(~min(HstW),~max(HstW)),
label = ‘Height st Width’, values = ~HstW),
list(range = c(~min(minHW),~max(minHW)),
label = ‘Min Height Width’, values = ~minHW),
list(range = c(~min(minWD),~max(minWD)),
label = ‘Min Width Diameter’, values = ~minWD),
list(range = c(~min(rfBlock),~max(rfBlock)),
label = ‘RF Block’, values = ~rfBlock)
)
)

p