R 连续色彩美学的三元问题
使用plotly在R中创建三元图时发现了一个问题。如果颜色美学是一个连续变量,则三元图的背景中似乎有一个二元图。离散的色彩美学似乎工作得很好。有人知道怎么解决吗R 连续色彩美学的三元问题,r,plotly,r-plotly,R,Plotly,R Plotly,使用plotly在R中创建三元图时发现了一个问题。如果颜色美学是一个连续变量,则三元图的背景中似乎有一个二元图。离散的色彩美学似乎工作得很好。有人知道怎么解决吗 library(tidyverse) library(plotly) # Make a dataframe df<-data.frame(ID = 1:6, ID2 = c(rep("B14",4),"B16","B16"), Location = c(40.
library(tidyverse)
library(plotly)
# Make a dataframe
df<-data.frame(ID = 1:6,
ID2 = c(rep("B14",4),"B16","B16"),
Location = c(40.9,96,120,308.5,322,420),
Classifier = c(rep("A",3),rep("B",3)),
A = c(0.06,0.06,0.02,0.02,0.01,0.01),
B = c(0.04,0.01,0.03,0.04,0.02,0.06),
C= c(0.26,0.06,0.43,0.35,0.29,0.74),
X = c(363,696,757,1650,609,392)
)
颜色由连续变量在三元背景中创建两个附加轴
df %>%
plot_ly(
a = ~A,
b = ~B,
c = ~C,
text = ~ID,
color = ~X,
colors = "Spectral",
type = 'scatterternary',
mode = 'markers',
marker = list(
symbol ='circle',
opacity = 0.6,
size = 15
))
这不是一个解决方案,更像是一个问题的面具。可以像这样隐藏x轴和y轴:
ax <- list(
title = "",
zeroline = FALSE,
showline = FALSE,
showticklabels = FALSE,
showgrid = FALSE
)
# use your df:
df %>%
plot_ly(
a = ~A,
b = ~B,
c = ~C,
text = ~ID,
color = ~X,
colors = "Spectral",
type = 'scatterternary',
mode = 'markers',
marker = list(
symbol ='circle',
opacity = 0.6,
size = 15
)) %>%
layout(xaxis = ax, yaxis = ax)
ax%
阴谋(
a=~a,
b=~b,
c=~c,
text=~ID,
颜色=~X,
colors=“光谱”,
类型='scatterTrimal',
模式='标记',
标记=列表(
符号='圆',
不透明度=0.6,
尺寸=15
)) %>%
布局(xaxis=ax,yaxis=ax)
ax <- list(
title = "",
zeroline = FALSE,
showline = FALSE,
showticklabels = FALSE,
showgrid = FALSE
)
# use your df:
df %>%
plot_ly(
a = ~A,
b = ~B,
c = ~C,
text = ~ID,
color = ~X,
colors = "Spectral",
type = 'scatterternary',
mode = 'markers',
marker = list(
symbol ='circle',
opacity = 0.6,
size = 15
)) %>%
layout(xaxis = ax, yaxis = ax)