如何使用散点图在散点图中显示第二个图例的第二个图例?

问题描述 投票:1回答:1

我有以下代码生成散点图(使用中的),我想添加来表示标记totalValue的大小(这是一个连续变量,表示标记的值特定建筑物),我该怎么办?

 f <- list(
   family = "Courier New, monospace",
   size = 18,
   color = "#7f7f7f"
  )
 x <- list(
   title = "Age of Buildings",
   titlefont = f,
   zeroline = FALSE,
   showline = FALSE,
   showticklabels = TRUE,
   showgrid = TRUE
  )
  y <- list(
    title = "Total Violations",
    titlefont = f,
    zeroline = FALSE,
    showline = FALSE,
    showticklabels = TRUE,
    showgrid = TRUE
   )
fig2 <- plot_ly(final, x=~agebuilding, y=~violationstotal, mode= "markers", color = 
                ~INdexrehabless6, size = ~totalvalue)
fig2 <- fig2 %>% layout(xaxis = x, yaxis = y, legend=list(title=list(text='<b> 
                        Housing Conditions </b>'))) #chaging name legend
fig2

数据集样本:

agebuilding  violationstotal  INdexrehabless6  totalvalue
32            5                0                 350000
120          15                1                  50000
100          25                1                 100000
32           31                0                 210000
33            9                0                 150000
50           20                0                 301000
15           28                0                 175000
70           18                1                 125000

这是我得到的情节

enter image description here

r plotly data-visualization legend r-plotly
1个回答
0
投票
据我所知,尚无法在中绘制两个图例:
© www.soinside.com 2019 - 2024. All rights reserved.