我是R的新手。我在下面的import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
modelValue: any;
onChange(value) {
this.modelValue = confirm(`Are you sure you want to update the model value with ${value}?`) ? value : this.modelValue;
console.log('Model Value is: ', this.modelValue);
}
}
图表中对geom_text
元素的排序遇到麻烦。
我相信这与geom_col
行有关,但我不确定。
附加了示例代码和输出。如您所见,标签错误-position = position_dodge2(preserve = "single")
和e
以及b
和a
都应该切换。
睁大眼睛(也许头脑更聪明)的人可以看到问题所在吗?
d
答案 0 :(得分:1)
好工作。也许您可以尝试在group = Importance
的美感中添加geom_text
。也就是说,要“明确定义分组结构”,请参见grouping。另外,here是一个相关案例。
ggplot(data, aes(x = Importance, y = Current.Capability, fill=Function)) +
geom_col(position = position_dodge2(preserve = "single"), width = width) +
facet_grid(~Importance, scales = "free_x", space = "free_x") +
geom_text(
aes(
label = stringr::str_wrap(Item, 50),
group = Importance), # explicitly define the grouping structure
lineheight = 0.7,
angle=90,
size = 5,
hjust=0,
vjust=0.5,
y = 0.5,
position = position_dodge2(preserve = "single", width = position.width)) +
theme(axis.text.x = element_blank(), axis.ticks = element_blank()) +
theme(legend.position="bottom")+
scale_y_discrete(limits = c("Undeveloped", "Basic", "Advanced", "World class")) +
xlab("Importance") + ylab("Current Capability")