有没有办法在Plotly中使用单个图例来实现多重美学?我使用ggplot来绘制几周的数据,它会变得非常嘈杂。因此,我使用颜色和形状来区分它们,ggplot只是将它们组合在图例中。这是一个可重复的例子:
p<- ggplot(mtcars, aes(mpg,wt))+
geom_point(aes(color = factor(gear), shape = factor(gear)))+
geom_line(aes(color = factor(gear)))
p
现在,如果我使用
ggplotly(p)
我得到以下情节,其中显示了两组传奇。有没有办法让Plotly传奇像ggplot那样表现?
由于
答案 0 :(得分:1)
我认为ggplot2 / plotly可能仍然存在问题。或者,您可以尝试:
class DisablingRule implements TestRule {
Collection<Features> readFromFile = new ArrayList<>();
public DisablingRule(String configfile) {
// read config file to find out what features are supposed to be supported
// and add to member
Files.readAllLines(Paths.get(configfile), Charset.UTF8).stream()
.map(Feature1::valueOf)
.forEach(readFromFile::add);
}
public Statement apply(Statement base, Description d) {
return (isFeatureEnabled(d.getAnnotation(FeatureSupport.class)))
? base
: () -> {
log(String.format("Test case %s disabled: feature not supported: %s",
d.getDisplayName(), feature)); };
}
}
private boolean isFeatureEnabled(FeatureSupport f) {
return f != null || readFromFile.contains(f.getCondition());
}
}