r - 当我在同一个图中绘制函数和条形图时出现轴问题
问题描述
当我绘制两个图表(一个函数和一个条形图)时,我遇到了轴问题。
我已经尝试将轴 = FALSE。虽然效果不好...
这是我的代码:
n = 64
p = 0.5
tailleEchantillon<-1000
m = n * p
sigma = sqrt(n * p * (1 - p))
borne_sup = m+7*sigma
borne_inf = m-7*sigma
x = 0:n
echantillon = rbinom(tailleEchantillon,n,p)
tabEffectifs = NULL
for (i in x) {tabEffectifs = c(tabEffectifs,length(echantillon[echantillon == i]))}
print("Tableau des effectifs")
print(table(echantillon,deparse.level=2))
texteLegende1<-bquote(p == .(p))
texteTitre1 = ""
barplot(tabEffectifs,las=1,names.arg=x,col="blue",ylim=c(0,(tailleEchantillon/4)),legend.text=texteLegende1,main=texteTitre1,xlab="k",ylab="Effectifs",cex.main=1)
tabFrequences = tabEffectifs/tailleEchantillon
plot(function(x) dnorm(x, m, sigma), borne_inf, borne_sup, legend.text="Courbe loi normale", ylim=c(0,0.10), xlab="x", ylab="prob")
par(new = T)
barplot(tabFrequences,las=1,names.arg=x, col="red", ylim=c(0,0.10),legend.text=texteLegende2,main=texteTitre2,xlab="k",ylab="Densites",cex.main=1)
有人知道我如何通过叠加轴避免这个问题吗?谢谢。
解决方案
推荐阅读
- laravel - 发生错误:ArtisanLambdaFunction - 解压后的大小必须小于 220606645 字节(服务:Lambda,状态码:4000
- mongodb - 如何使用 mongodb 在环回 4 中实现 groupBy?
- react-native - 从图库中获取图像的 url 并将图像从设备转换为 tensor3d
- git - 如果不存在标签,则获取第一次提交
- java - Android Studio (Windows) 中的 Flutter 错误:无法识别的选项:--add-opens
- reactjs - 如何使用 Storybook 制作别名?
- django - 通用 DeleteView 在 0x04725628 返回 django.db.models.query_utils.DeferredAttribute 对象 - Django
- microsoft-graph-api - ms botframework 附件无法生成共享链接
- android - 无法在 Android Studio 中添加其他平台/构建工具
- javascript - SVG:如何绘制多个半圆(弧)路径