如何在 R 中绘制线图?
我正在尝试使用 R 制作 Excel 类型的线图,其中我的 x 轴是文本(A、B、c 等),y 轴(可以是负值和正值)是上下列。我想放弃红色而放弃绿色。
如果有人能在这方面帮助我,我将非常感激。我已经在 Excel 中绘制了此图,但我的数据中有数千行,并且 Excel 没有显示图中的所有文本点。
我的数据如下所示:
Name UP Downs
A 10 -3
B 2 -4
C 1 -1
D 4 -1
E 5 0
F 0 -1
G 6 -5
H 0 -1
I 7 -1
J 0 -1
K 0 -11
L 3 -1
M 0 -13
N 2 -1
O 0 -1
P 1 -1
Q 0 0
R 1 -1
S 0 0
T 12 -1
I am trying to use R to make an excel kind of a line plot, where my x axis is text (A,B,c..etc) and the y axis(which can be both negative and positive) are up and down columns. I want to give up a red color and down green.
I would really appreciate if anyone can help me regarding this. I have plotted this in excel but i have thousands of rows in my data and excel doesnot show all the text point in my plot.
My data looks like the following:
Name UP Downs
A 10 -3
B 2 -4
C 1 -1
D 4 -1
E 5 0
F 0 -1
G 6 -5
H 0 -1
I 7 -1
J 0 -1
K 0 -11
L 3 -1
M 0 -13
N 2 -1
O 0 -1
P 1 -1
Q 0 0
R 1 -1
S 0 0
T 12 -1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能不是最优雅的方法,但您可以使用
plot
、points
和axis
(< code>axis 是主要的,它解释了如何更改轴上的标签):?axis
、?plot
、?points
。首先制作一个与您类似的数据框,以便我可以演示...
现在绘制。
根据需要进行调整:
?points
和?par< /code> 和
?axis
在这方面特别有帮助。This is probably not the most elegant way to do it, but you can work it all out using with
plot
,points
, andaxis
(axis
is the main one, it explains how you can change the labels on the axis):?axis
,?plot
,?points
.First make a data frame similar to yours so I can demonstrate...
Now plot.
Tweak it as you wish:
?points
and?par
and?axis
are particularly helpful in this respect.