これはおそらくそれを行うための最もエレガントな方法はありませんが、plot
を使用して、すべてをうまくすることができ、points
、およびaxis
(axis
がメインです1つは軸のラベルをどのように変更できるか説明しています)?axis
,?plot
、?points
です。
まず今のプロット...ので、私は証明できる
# make a data frame similar to yours
mydf <- data.frame(Name=LETTERS,
Up=sample.int(15,size=26,replace=T),
Down=-sample.int(15,size=26,replace=T))
をあなたに似たデータフレームを作ります。
# set up a plot: x axis goes from 1 to 26,
# y limit goes from -15 to 15 (picked manually, you can work yours out
# programmatically)
# Disable plotting of axes (axes=FALSE)
# Put in some x and y labels and a plot title (see ?plot...)
plot(0,xlim=c(1,26),ylim=c(-15,15),type='n',
axes=FALSE, # don't draw axis -- we'll put it in later.
xlab='Name',ylab='Change', # x and y labels
main='Ups and Downs') #,frame.plot=T -- try if you like. ?plot.default
# Plot the 'Up' column in green (see ?points)
points(Up~Name,mydf,col='green')
# Plot the 'Down' column in red
points(Down~Name,mydf,col='red')
# ***Draw the x axis, with labels being A-Z
# (type in 'LETTERS' to the prompt to see what they are)
# see also ?axis
axis(1,at=1:26,labels=LETTERS)
# Draw the y axis
axis(2)
あなたが望むようにそれを微調整:?points
と?par
と?axis
は、この点で特に有用です。
[ドキュメントはお友達です。それを読んで。大好きです。それを使用してください。](http://stat.ethz.ch/R-manual/R-devel/library/graphics/html/plot.html) –
私はこのページを読んでいます...問題は私のxaxisはテキストです。 .. – RnD
@ mathematical.coffe .i csvファイルを "nba"変数にインポートして、plot(nba [、1]、nba [、2])と打ち込んでください...何が私に何を与えてくれないのですか? – RnD