我使用了点阵包装绘制线图。
library(lattice)
xyplot(price~month,groups=perc,data=Edf,type='l',
main="Percentile chart of OpRes Charge Rates Forcast",
ylab="OpRes Charge Rate ($/MWh)", xlab="Months",ylim=c(0,40),auto.key=TRUE)
Run Code Online (Sandbox Code Playgroud)
然后,我想在现有绘图上添加一些点。
points(rep(1,length(OpResWestJan)),OpResWestJan)
Run Code Online (Sandbox Code Playgroud)
OpResWestJan 是向量,但点从未出现在现有图中,也没有警告。
这是我的代码:
function test(n)
r = (0:1000)/n;
Phi = 2*pi*r;
[x,y] = pol2cart(Phi,r);
plot(x,y)
end
Run Code Online (Sandbox Code Playgroud)
这是n = 100,10,1的输出顺序:

最后一张图表发生了什么?它为什么吓坏了?>.> ......
n = 1后更有趣的形状:这里n = 0.9,0.8,0.7,0.6

在R,给定的数据帧df与列名y,x1,x2,...,xn,如何可以绘制xiVS y对所有xi在所述数据帧,而无需手动输入
plot(df$y,df$xi,...)
Run Code Online (Sandbox Code Playgroud)
对于所有$ i $,以便我得到n不同的图,一次性使用适当的轴名称(列名称)?
编辑:我的数据框看起来像这样
Price SqFt Rooms Something Age
1 53.5 1008 5 2 35
2 49 1290 6 3 36
3 50.5 860 8 2 36
4 49.9 912 5 3 41
5 52 1204 6 3 40
6 55 1024 5 3 10
7 80.5 1764 8 4 64
8 86 1600 7 3 19
Run Code Online (Sandbox Code Playgroud)
我想Price在y轴上获得几个单独的图形,每个图形在x值上具有不同的列.对于4-5列,可以手动完成,但我有200多列的数据帧,所以我想自动化该过程.
我一直在网站上阅读几个类似的问题,但我没有太多运气得到答案,以适应我的特殊情况.我不习惯处理数据帧.
先感谢您.
编辑:显然我甚至不能SqFt反对Price …
你能帮我用ggplot2包和mat矩阵中的数据创建下面的条形图吗?
mat <- matrix(c(70.93,78.58,78.72,69.24,62.53,43.85,83.49,70.00,78.30,78.11,71.16,63.82,47.37,89.87),ncol=2)
colnames(mat) <- c("Crude","Standardized")
rownames(mat) <- 2006:2012
library(gplots)
library(RColorBrewer)
my_palette <- palette(brewer.pal(7,"Set1"))
barplot2(mat,
main="Crude and Standardized Rates",
xlab="Type", ylab="Rate", xlim=c(0,20), ylim=c(40,100),
col=my_palette, beside=TRUE, plot.grid = TRUE, xpd=FALSE)
legend(locator(1), rownames(mat), title ="Year",fill=my_palette)
Run Code Online (Sandbox Code Playgroud)

此代码将在一个窗口中显示几个图.因为每个图是根据名为X1到X13的每个列产生的.所以我想在as a main每个图形中添加用于绘制图形的列的名称,以便区分哪个是哪个
.
ref= read.table("D:\\AS_asc.txt", sep="",header=TRUE)
sour1 = read.table("D:\\re.txt", sep="",header=TRUE)
sour2= read.table("D:\\_asc.txt", sep="",header=TRUE)
columns <- paste0("X", 1:13)
par(mfrow=c(4,4))
lapply(
columns,
function(column)
{
result1 <- (
mean(ref[[column]]) -
((sd(ref[[column]]) / sd(sour1[[column]])) * mean(sour1[[column]])) +
((sd(ref[[column]]) / sd(sour1[[column]]) * sour1[[column]]))
) # calculate using ref and sour1
result2 <- ((
mean(ref[[column]]) -
((sd(ref[[column]]) / sd(sour2[[column]], na.rm=TRUE)) * mean(sour2[[column]], na.rm=TRUE)) +
((sd(ref[[column]]) / sd(sour2[[column]], na.rm=TRUE) * sour2[[column]]))
)) # calculate using ref and sour2
plot(
ref[[column]],
result1,
ylab = "[[column]]", …Run Code Online (Sandbox Code Playgroud) 我经常去网站:http: //gadm.org 找到我想用R绘制的国家的轮廓.但今天,这个网站已关闭,我不知道如何继续准确地图...
当我尝试:
library(maps)
map("world", xlim=c(15,23), ylim=c(45.5,49))
Run Code Online (Sandbox Code Playgroud)
这个国家的轮廓不是很准确......
我试图找到一个可以给出轮廓的其他网站,但我没有找到.
有人可以帮帮我吗?
我用R来绘制统计图.我可以绘制简单的图表.但是,我不知道如何绘制复杂数据.
有人可以帮我把所有这些信息整理成图表吗?不包括N(计数).
我的数据集
$ df <- read.csv("database.csv", header=TRUE, sep=",")
$ df
# df is 'data frame'
# Gives count (N), mean, standard deviation (sd), standard error of the mean (se),
# and confidence interval (ci)
method N mean sd se ci
4 A 100 0.3873552 0.014513971 0.0014513971 0.002879887
6 B 100 0.3873552 0.014513971 0.0014513971 0.002879887
11 C 100 0.3873552 0.014513971 0.0014513971 0.002879887
12 D 100 0.3873552 0.014513971 0.0014513971 0.002879887
10 E 100 0.3757940 0.027337627 0.0027337627 0.005424378
1 F 100 0.3715910 …Run Code Online (Sandbox Code Playgroud) 我有一个由以下R代码生成的图 - 基本上是许多直方图/条的面板.我希望每一个都添加一条垂直线,但每个方面的垂直线在它的位置上是不同的.或者,我想根据x值是否高于阈值将条纹颜色设置为红色 - 如何使用ggplot2/R对此进行绘图.
我这样生成了图表:
Histogramplot3 <- ggplot(completeFrame, aes(P_Value)) + geom_bar() + facet_wrap(~ Generation)
Run Code Online (Sandbox Code Playgroud)
在completeFrame是我的数据框架的地方,P_Value是我的x变量,而Facet Wrap Variable Generation是一个因素.
所以我在R中创建了这个简单的线图,我想知道如何将y轴从图片中的内容更改为:
1000000
100000
10000
1000
100
10
1
Run Code Online (Sandbox Code Playgroud)
并且x轴也只是从1到25跨越,包括每个刻度.
我试过了:
plot(dataTable[0:25], axes=FALSE)
axis(1, at=seq(0, 25, 1))
axis(2, at=c(1,10,100,1000,10000,100000,1000000))
Run Code Online (Sandbox Code Playgroud)
dataTable的位置如下所示:
1 2 3 4 5 6 7 8 9 10 11
621266 496647 436229 394595 353249 305882 253983 199455 147380 102872 67255
12 13 14 15 16 17 18 19 20 21 22
41934 24506 13778 7179 3646 1778 816 436 217 114 74
23 24 25
49 44 26
Run Code Online (Sandbox Code Playgroud)
但我一直在努力
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' and …Run Code Online (Sandbox Code Playgroud) 我想在我的情节中向y轴添加逗号,但到目前为止我尝试的东西不起作用:
matplot(X, Y, type = "l", col = "green", xlab = "Time (years)", ylab = "Cost", main = "BLANK", ylim = (30000,60000), xlim = c(0,15))
Run Code Online (Sandbox Code Playgroud)
就是我拥有的.
不确定如何在30,000 - 60,000上添加逗号,该逗号应出现在y轴上.
编辑:对不起,我在matplot标签中的意思是:http://stat.ethz.ch/R-manual/R-patched/library/graphics/html/matplot.html