显示轴顶上图表上点上点的正确方法是什么?
有时需要在轴顶部的图表上显示点,以便结果看起来像这样:
以前,当我使用 R 时,需要一定的炼金术才能获得期望的结果:第一设置渲染字段的大小,然后设置轴的位置,最后在所有这些之上绘制数据点:
f <- rnorm(10, mean=5, sd=1)
plot(x = f, y = c(rep(0, 10)), xlim = c(-1, 11), ylim = c(0, 1),
axes = FALSE, box = FALSE, xaxs = "i", ylab="")
abline(h=0)
axis(side = 1, at = seq(0, 10, 2), pos = 0, tck = -0.02)
points(x = f, y = c(rep(0, 10)), cex=1.0, pch = 21,
col="black", bg="white", lwd = 1)
现在我正在尝试将整个工作流程转换为 Julia,我想找到一些替代方案这样的可视化。我通常使用 Plots.jl 和 GR 后端。我在 R 中使用的技巧在这种情况下不起作用:当在上面添加一层时,它仍然被开头设置的画布边框切断:
c = vcat(1.0, 3.0, 4.0, 6.0, 7.0, 9.0, 12.0, 21.0)
plot(c, zeros(length(c)), seriestype = :scatter,
markersize=5, markershape=:circle, color = :white, label = "", ylims=(0,Inf))
plot!(c, zeros(length(c)), seriestype = :scatter,
markersize=5, markershape=:circle, color = :white, label = "")
结果:
最合理的方法是什么和朱莉娅一起得到这样的图形吗?
Sometimes there is a need to display points on the graph on top of the axes so that the result looks something like this:
Previously, when I used R, it took a certain amount of alchemy to get the desired result: first the size of the rendering field was set, then the position of the axis, and at the end data points were drawn on top of all this:
f <- rnorm(10, mean=5, sd=1)
plot(x = f, y = c(rep(0, 10)), xlim = c(-1, 11), ylim = c(0, 1),
axes = FALSE, box = FALSE, xaxs = "i", ylab="")
abline(h=0)
axis(side = 1, at = seq(0, 10, 2), pos = 0, tck = -0.02)
points(x = f, y = c(rep(0, 10)), cex=1.0, pch = 21,
col="black", bg="white", lwd = 1)
Now I'm trying to translate my entire workflow to Julia and I want to find some alternative for such visualization. I usually use Plots.jl with GR backend. The trick I used in R does not work in this case: when adding a layer above, it is still cut off by the canvas borders set at the beginning:
c = vcat(1.0, 3.0, 4.0, 6.0, 7.0, 9.0, 12.0, 21.0)
plot(c, zeros(length(c)), seriestype = :scatter,
markersize=5, markershape=:circle, color = :white, label = "", ylims=(0,Inf))
plot!(c, zeros(length(c)), seriestype = :scatter,
markersize=5, markershape=:circle, color = :white, label = "")
Result:
What is the most rational way to get such graphics with Julia?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够通过使用
framestyle =:Origin
或framestyle =:zerolines
,如果您想显示显示只是X-X-axis
You should be able to plot on the x-axis by using
framestyle=:origin
orframestyle=:zerolines
and if you want to show just the x-axis