Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.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 带有ggplot2的极坐标图中缺少值_R_Plot_Ggplot2 - Fatal编程技术网

R 带有ggplot2的极坐标图中缺少值

R 带有ggplot2的极坐标图中缺少值,r,plot,ggplot2,R,Plot,Ggplot2,我正在使用ggplot2绘制极坐标图。 360附近的数据丢失。 如何显示所有数据? 以下是数据和代码 Angle Geno 1.252 5 329.714 5 334.74 5 348.166 5 18.29 5 3.035 5 359.855 5 358.348 5 359.855 5 9.317 5 6.195 5 355.281 5 333.29 5 349.235 5 359.855 5 1.219 5 2.058 5 342.205 5 1.764

我正在使用ggplot2绘制极坐标图。 360附近的数据丢失。 如何显示所有数据? 以下是数据和代码

Angle   Geno
1.252   5
329.714 5
334.74  5
348.166 5
18.29   5
3.035   5
359.855 5
358.348 5
359.855 5
9.317   5
6.195   5
355.281 5
333.29  5
349.235 5
359.855 5
1.219   5
2.058   5
342.205 5
1.764   5
345.321 5
345.234 5
337.606 5
39.661  5
328.425 5
347.59  5
348.545 5

i=5

Hist_LR_Geno你有两个问题。首先,您使用了
geom_histogram
,它统计每个箱子中的行数,但看起来您可能实际上想要每个箱子中的
Geno
之和。让我们暂时忽略这一点,继续使用
geom\u直方图
。请多说一下你到底想做什么,我们可以稍后再讨论这个问题

正如我所说,
geom_直方图
统计每个箱子中的行数。但对于某些直方图条,该行数大于5。但是,您已经设置了
scale\u y\u continuous
,限制为
c(-5,5)
。因此,任何高于5的钢筋都将被移除。以下是y极限较大的图:

p5 + geom_histogram(binwidth=22.5) + 
  scale_y_continuous(limits = c(-5, 12), breaks=0:12) +
  scale_x_continuous(limits=c(0,360), breaks=seq(0,360-45,45)) +
  coord_polar(start=pi, direction=-1) 

更新:关于您的评论:是的,我遇到了与
scale\u y\u continuous
相同的问题。您的
scale\u x\u continuous
也会排除值,因为条形图具有宽度。最低的条延伸到零以下,最高的条延伸到360以上,因此当x限制设置为0到360时,这两个条都被排除在外。我们可以扩展x限制,但是x值必须从-22.5/2到360+22.5/2,而不是从0到360

相反,让我们更改存储箱的位置,使第一个存储箱适合0到22.5之间(而不是-22.5/2和22.5/2之间),最后一个存储箱适合360-22.5和360之间(而不是360-22.5/2和360+22.5/2之间)。我们可以使用
geom\u直方图的
center
参数来实现这一点。您只需给出一个箱子的中心,其余的箱子将进行相应的调整

p5 + geom_histogram(binwidth=22.5, colour="white", center=22.5/2) + 
  scale_y_continuous(limits = c(-5, 14), breaks=0:15) +
  scale_x_continuous(breaks=seq(0,360,45)) +
  coord_polar(start=pi, direction=-1) 

你想做什么?目前还不清楚希望得到什么样的结果。问题在于没有在边缘区域、0度和360度显示数据。参数“center”是必需的。谢谢,eipi10。是的,那是个错误。我可以修正范围“limits=c(-5,12)”。但是,仍然只有14个数据。再次感谢,eipi10!!“中心=22.5/2”工作正常。如果没有这一点,则不会显示0-11.25和348.5-360之间的数据。
p5 + geom_histogram(binwidth=22.5, colour="white", center=22.5/2) + 
  scale_y_continuous(limits = c(-5, 14), breaks=0:15) +
  scale_x_continuous(breaks=seq(0,360,45)) +
  coord_polar(start=pi, direction=-1)