我有以下数据:
251
63
0
-109
15
0
0
139
-182
0
94
-110
0
-155
-103
39
-106
0
-225
-99
89
-128
145
122
0
0
-58
158
-115
-115
0
0
141
-33
-148
-41
55
0
77
92
-174
91
-82
130
18
119
0
128
103
35
-119
0
-184
88
83
-35
-164
129
0
-94
-102
-129
78
-58
44
0
90
-262
-217
0
0
-157
0
0
-66
0
0
76
0
36
-135
0
0
0
50
0
0
55
0
0
0
0
0
-123
0
-92
-151
-119
0
0
0
57
3
0
151
0
0
-102
-123
75
-88
0
147
2
0
0
0
-89
0
0
-68
159
-63
86
-192
114
-103
0
-84
97
0
0
18
0
0
-103
0
0
-154
-64
0
-151
9
35
0
-140
0
-122
-149
-209
0
-98
0
107
0
-104
140
70
0
96
0
-37
0
-205
80
0
-93
-68
-101
12
-141
-92
0
0
0
88
0
0
0
0
12
-133
0
0
0
56
0
0
226
0
101
-124
236
-30
0
-143
73
-176
193
0
29
67
0
149
65
0
125
65
-82
-126
132
0
84
-103
0
9
37
91
-111
-125
-53
-194
200
-63
80
-97
-86
163
0
0
0
60
0
132
0
-162
0
0
0
98
68
0
40
0
0
87
-93
77
-127
0
13
-148
0
88
202
0
-132
0
-99
0
-116
0
-162
0
0
0
0
-36
0
0
0
0
0
-75
0
100
100
48
-148
-44
0
0
27
-111
144
-156
0
0
-20
-97
-187
56
-148
0
-34
0
0
-163
0
6
6
208
110
-102
-64
93
0
0
116
-105
-111
80
-126
-203
-86
0
0
1
-96
0
0
0
0
187
0
-76
34
-67
96
0
0
0
0
0
0
0
90
72
126
-71
-109
0
124
0
0
0
0
0
16
65
-190
0
0
0
43
93
-67
-87
80
154
0
-210
80
203
-70
-154
0
0
-64
-84
-102
0
-141
0
0
-141
42
-84
0
89
0
0
-151
-97
-22
-100
0
140
-155
0
0
-191
83
130
207
-48
-92
29
0
0
0
0
-147
0
-72
我想在R中生成这样的图(下面的图是在excel中生成的)。任何指示?我试过,绘制命令,但它没有生成我喜欢的那个。
数据在y轴上围绕“0”值映射(在excel中生成的图中),x轴可以被视为行号或类似的东西。
请帮助。提前谢谢。
答案 0 :(得分:1)
首先将数据放入更有用的格式:
y <- c(0, -99, 0, -116, 0, -162, 0, 0, 0, 0, -36, 0, 0, 0, 0, 0, -75,
0, 100, 100, 48, -148, -44, 0, 0, 27, -111, 144, -156, 0, 0,
-20, -97, -187, 56, -148, 0, -34, 0, 0, -163, 0, 6, 6, 208, 110,
-102, -64, 93, 0, 0, 116, -105, -111, 80, -126, -203, -86, 0, 0,
1, -96, 0, 0, 0, 0, 187, 0, -76, 34, -67, 96, 0, 0, 0, 0, 0, 0,
0, 90, 72, 126, -71, -109, 0, 124, 0, 0, 0, 0, 0, 16, 65, -190,
0, 0, 0, 43, 93, -67, -87, 80, 154, 0, -210, 80, 203, -70, -154,
0, 0, -64, -84, -102, 0, -141, 0, 0, -141, 42, -84, 0, 89, 0,
0, -151, -97, -22, -100, 0, 140, -155, 0, 0, -191, 83, 130,
207, -48, -92, 29, 0, 0, 0, 0, -147, 0, -72)
现在基本情节只是
plot(y)
但这与你的例子不太相似,所以让我们添加。
plot(NA, xlab="", ylab="", ylim=c(-300, 300), xlim=c(0, 150), las=1)
grid(lty=1)
points(y, pch=16, col="blue")
答案 1 :(得分:0)
这有用吗?
d0 = "
1
2
3"
d = read.table(text = d0, header=F)
ggplot(d, aes(seq_along(V1), V1)) + geom_point()
或者plot(d[,1])
可以使用。
答案 2 :(得分:0)
做x-y情节
x <- c(251, 63, 0, -109, 15, 0, 0)
y <- c(139, -182, 0, 94, -110, 0, -155)
plot(x, y)