Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
一张图中的两个对数R图:添加纹理或图案+;将杆定心在零位_R_Plot_Histogram - Fatal编程技术网

一张图中的两个对数R图:添加纹理或图案+;将杆定心在零位

一张图中的两个对数R图:添加纹理或图案+;将杆定心在零位,r,plot,histogram,R,Plot,Histogram,对于可用的两列数据,我在RStudio的一个图中绘制了两个对数y轴直方图: data = read.table("C:\\test\\test.csv", header=TRUE, sep=",") par( mar=c(3.1, 5.1, 0, 0)) hist.x <- hist(data$a, plot = FALSE, breaks=50) hist.x$counts <- log10(hist.x$counts + 1) plot(

对于可用的两列数据,我在RStudio的一个图中绘制了两个对数y轴直方图:

data = read.table("C:\\test\\test.csv", header=TRUE, sep=",")
par( mar=c(3.1, 5.1, 0, 0)) 
hist.x <- hist(data$a, plot = FALSE, breaks=50)
hist.x$counts <- log10(hist.x$counts + 1)
plot(hist.x, col = rgb(0, 0, 1, 0.99), main="", xlab="", ylab="", yaxt="n")
yAxesTitles=c(1, 10, 100, 1000, 10000)
axis(2, at=c(0, 1, 2, 3, 4),labels=yAxesTitles, col.axis="black", las=2)
mtext(side = 3, text = "a vs b", line = 0, cex=1.3)
mtext(side = 1, text = "Number", line = 2)
mtext(side = 2, text = "Frequency", line = 4)
# Adding the second diagram to the first one:
relocatedData=data$b+0.2
hist.y <- hist(relocatedData, plot = FALSE, breaks=50)
hist.y$counts <- log10(hist.y$counts + 1)
plot(hist.y, col = rgb(1, 0, 0, 0.99), main="", xlab="", ylab="", yaxt="n", add=TRUE)
legend(7.5, 4, c("a", "b"), lwd=c(1, 1), col=c(rgb(0, 0, 1, 0.99), rgb(1, 0, 0, 0.99)), pch = c(15, 15), pt.cex=2)
data=read.table(“C:\\test\\test.csv”,header=TRUE,sep=“,”)
par(mar=c(3.1,5.1,0,0))

hist.x我无法重新创建您的绘图,但对于第一个问题,您是否尝试添加
密度
参数?例如,
plot(hist.y,col=“red”,density=5,angle=45,…)
应该可以做到这一点-这里,
..
代表了您的其余选项。还可以尝试使用
set.seed(3)
data@Therkel运行代码,谢谢您的评论。我可以应用第一个(虽然我以前尝试过密度,但现在我发现我需要col=“red”而不是col=rgb(1,0,0,0.99);换句话说,rgb()不适用于密度)。