在下面的代码中,Existing Customers Data
与Sales History
重叠,因此显示Existing Customers
数据的位置略高Rr,并且更靠右
common<-structure(list(criteria = c("Customer Activity", "Existing Customers Data",
"Prospect Data", "Sales History"), priority.x = c("0.25", "0.27",
"0.20", "0.27"), priority.y = c("0.25", "0.31", "0.13", "0.31"
)), row.names = c(NA, -4L), class = "data.frame")
> library(ggplot2)
# Assuming 'common' is your data frame
# Creating the plot
ggplot(common, aes(x = as.numeric(priority.y), y = as.numeric(priority.x))) +
geom_text(aes(label = criteria)) +
xlim(-0.5,0.5) + ylim(-0.5, 0.5) +
geom_hline(yintercept = 0) + geom_vline(xintercept = 0) +
labs(title = "Optimization Matrix",
x = "Feasibility",
y = "Business Values") +
theme_minimal() +
theme(axis.text.x = element_blank(), axis.text.y = element_blank())
字符串
1条答案
按热度按时间ktca8awb1#
你至少有两个选择。
你可以使用ggrepl包中的geom_text_repel:
字符串
(You可以使用box.padding的参数)
或者你可以在geom_text()的选项中使用check_overlap = TRUE。但是这会屏蔽一些标签。
最后一点,把priority.y作为x轴,把priority.x作为y轴有点奇怪,也许你应该重命名你的变量以避免任何错误。