改变情节的外观和感觉以类似于历史
我使用这篇文章中的信息创建了一个具有对数刻度的直方图: 具有对数刻度的直方图
但是,plot 的输出看起来与 hist 的输出完全不同。有谁知道如何配置绘图的输出以类似于 hist 的输出?感谢您的帮助。
I used the information from this post to create a histogram with logarithmic scale:
Histogram with Logarithmic Scale
However, the output from plot looks nothing like the output from hist. Does anyone know how to configure the output from plot to resemble the output from hist? Thanks for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
链接答案的简化、可重现版本是
为了让轴看起来更像“hist-like”,请将最后一行替换为
使用此方法将条形图连接起来将是一场噩梦。我建议使用
lwd
值进行反复试验(在本例中,34 看起来很接近正确),或者学习使用lattice
或ggplot.
编辑:
您无法设置边框颜色,因为条形并不是真正的矩形 - 它们只是粗线。我们可以通过在顶部绘制稍细的线条来伪造边框效果。更新后的代码是
A simplified, reproducible version of the linked answer is
To get the axes looking more "hist-like", replace the last line with
Getting the bars to join up is going to be a nightmare using this method. I suggest using trial and error with values of
lwd
(in this example, 34 is somewhere close to looking right), or learning to uselattice
orggplot
.EDIT:
You can't set a border colour, because the bars aren't really rectangles – they are just fat lines. We can fake the border effect by drawing slightly thinner lines over the top. The updated code is
使用ggplot2怎么样?
但我同意哈德利在另一篇文章中的评论,即具有对数刻度的直方图对我来说似乎很奇怪 =)。
How about using ggplot2?
But I agree with Hadley's comment on the other post that having a histogram with a log scale seems weird to me =).