如何将我的散点图转换为正确的散点图?

发布于 2025-01-20 21:20:46 字数 2132 浏览 1 评论 0原文

我是R的新手,我想重新创建此散点图:

ggplot(satDf, aes(x=`Satisfaction Coefficient`, y=`Dissatisfaction Coefficient`)) + geom_point() + expand_limits(x=c(0.00, 1.00), y=c(0.00, -1.00))

将导致以下内容: ”“在此处输入图像说明”

satdf

“ https://i.sstatic.net/3nbju.png

"","Attribute","Satisfaction Coefficient","Dissatisfaction Coefficient"
"1","Create an enjoyable interaction","0.47","-0.43"
"2","Create an enjoyable interaction","0.38","-0.24"
"3","Create an enjoyable interaction","0.29","-0.17"
"4","Create an enjoyable interaction","0.49","-0.49"
"5","Create an enjoyable interaction","0.48","-0.36"
"6","Create an enjoyable interaction","0.36","-0.26"
"7","Create an enjoyable interaction","0.37","-0.4"
"8","Create an enjoyable interaction","0.32","-0.29"
"9","Create an enjoyable interaction","0.25","-0.16"
"10","Create an enjoyable interaction","0.61","-0.57"
"11","Create an enjoyable interaction","0.49","-0.49"
"12","Create an enjoyable interaction","0.08","-0.18"

>

structure(list(Attribute = c("Create an enjoyable interaction", 
"Create an enjoyable interaction", "Create an enjoyable interaction", 
"Create an enjoyable interaction", "Create an enjoyable interaction", 
"Create an enjoyable interaction"), `Satisfaction Coefficient` = c("0.47", 
"0.38", "0.29", "0.49", "0.48", "0.36"), `Dissatisfaction Coefficient` = c("-0.43", 
"-0.24", "-0.17", "-0.49", "-0.36", "-0.26")), row.names = c(NA, 
6L), class = "data.frame")
if(!require('ggplot2')) {
  install.packages('ggplot2')
  library('ggplot2')
}
satDf <- read.csv("")
ggplot(satDf, aes(x=`Satisfaction Coefficient`, y=`Dissatisfaction Coefficient`)) + geom_point(col="blue") + expand_limits(x=c(0.00, 1.00), y=c(0.00, -1.00)) + geom_text(label=rownames(satDf), nudge_x = -0.25, nudge_y = -0.25)

I'm new to r and I want to recreate this scatterplot: enter image description here
But I don't know how to get there. This is the code I have at this moment:

ggplot(satDf, aes(x=`Satisfaction Coefficient`, y=`Dissatisfaction Coefficient`)) + geom_point() + expand_limits(x=c(0.00, 1.00), y=c(0.00, -1.00))

which results in the following: enter image description here

satDf

enter image description here

CSV version of dataframe:

"","Attribute","Satisfaction Coefficient","Dissatisfaction Coefficient"
"1","Create an enjoyable interaction","0.47","-0.43"
"2","Create an enjoyable interaction","0.38","-0.24"
"3","Create an enjoyable interaction","0.29","-0.17"
"4","Create an enjoyable interaction","0.49","-0.49"
"5","Create an enjoyable interaction","0.48","-0.36"
"6","Create an enjoyable interaction","0.36","-0.26"
"7","Create an enjoyable interaction","0.37","-0.4"
"8","Create an enjoyable interaction","0.32","-0.29"
"9","Create an enjoyable interaction","0.25","-0.16"
"10","Create an enjoyable interaction","0.61","-0.57"
"11","Create an enjoyable interaction","0.49","-0.49"
"12","Create an enjoyable interaction","0.08","-0.18"

or

structure(list(Attribute = c("Create an enjoyable interaction", 
"Create an enjoyable interaction", "Create an enjoyable interaction", 
"Create an enjoyable interaction", "Create an enjoyable interaction", 
"Create an enjoyable interaction"), `Satisfaction Coefficient` = c("0.47", 
"0.38", "0.29", "0.49", "0.48", "0.36"), `Dissatisfaction Coefficient` = c("-0.43", 
"-0.24", "-0.17", "-0.49", "-0.36", "-0.26")), row.names = c(NA, 
6L), class = "data.frame")
if(!require('ggplot2')) {
  install.packages('ggplot2')
  library('ggplot2')
}
satDf <- read.csv("")
ggplot(satDf, aes(x=`Satisfaction Coefficient`, y=`Dissatisfaction Coefficient`)) + geom_point(col="blue") + expand_limits(x=c(0.00, 1.00), y=c(0.00, -1.00)) + geom_text(label=rownames(satDf), nudge_x = -0.25, nudge_y = -0.25)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷了相思 2025-01-27 21:20:46

您在寻找这样的东西吗?

satDf

您在寻找这样的东西吗?

Satisfaction Coefficient` <- as.numeric(satDf

您在寻找这样的东西吗?

Satisfaction Coefficient`) satDf

您在寻找这样的东西吗?

Dissatisfaction Coefficient` <- as.numeric(satDf

您在寻找这样的东西吗?

Dissatisfaction Coefficient`) ggplot(satDf, aes(x=`Satisfaction Coefficient`, y=-`Dissatisfaction Coefficient`)) + geom_label(x = 0.0, y = 0.55, label = 'Must - be', hjust = 0) + geom_label(x = 0.0, y = 0.45, label = 'Indifferent', hjust = 0) + geom_label(x = 1, y = 0.55, label = 'Performance', hjust = 1) + geom_label(x = 1, y = 0.45, label = 'Attractive', hjust = 1) + geom_point(col = 'deepskyblue3', size = 3) + geom_text(aes(label = seq(nrow(satDf))), size = 3, nudge_x = -0.015, nudge_y = -0.02, check_overlap = TRUE) + geom_text(aes(label = 11), size = 3, nudge_x = -0.015, nudge_y = 0.02, data = satDf[11,]) + theme_light() + theme(panel.grid = element_blank()) + geom_hline(yintercept = 0.5) + geom_vline(xintercept = 0.5) + scale_y_continuous(labels = function(x) paste0('-', x), limits = c(0, 1)) + xlim(c(0, 1))

输入图片此处描述

Are you looking for something like this?

satDf

Are you looking for something like this?

Satisfaction Coefficient` <- as.numeric(satDf

Are you looking for something like this?

Satisfaction Coefficient`) satDf

Are you looking for something like this?

Dissatisfaction Coefficient` <- as.numeric(satDf

Are you looking for something like this?

Dissatisfaction Coefficient`) ggplot(satDf, aes(x=`Satisfaction Coefficient`, y=-`Dissatisfaction Coefficient`)) + geom_label(x = 0.0, y = 0.55, label = 'Must - be', hjust = 0) + geom_label(x = 0.0, y = 0.45, label = 'Indifferent', hjust = 0) + geom_label(x = 1, y = 0.55, label = 'Performance', hjust = 1) + geom_label(x = 1, y = 0.45, label = 'Attractive', hjust = 1) + geom_point(col = 'deepskyblue3', size = 3) + geom_text(aes(label = seq(nrow(satDf))), size = 3, nudge_x = -0.015, nudge_y = -0.02, check_overlap = TRUE) + geom_text(aes(label = 11), size = 3, nudge_x = -0.015, nudge_y = 0.02, data = satDf[11,]) + theme_light() + theme(panel.grid = element_blank()) + geom_hline(yintercept = 0.5) + geom_vline(xintercept = 0.5) + scale_y_continuous(labels = function(x) paste0('-', x), limits = c(0, 1)) + xlim(c(0, 1))

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文