有没有办法在 Julia 中绘制布局,每个图使用不同的颜色?

发布于 2025-01-16 08:04:41 字数 229 浏览 3 评论 0原文

我正在尝试使用下面的代码在 Julia env 中绘制布局

x = 1:100
y = sin.(rand((Normal()), 100,4))
# plot
plot(x,y)
# layout
plot(x,y, layout = (4,1), color = [:red,:blue])

我期望的是每个图的颜色为红色或蓝色。结果是 4 个图同时具有红色和蓝色。我缺少什么?

I am trying to plot a layout in Julia env using the code below

x = 1:100
y = sin.(rand((Normal()), 100,4))
# plot
plot(x,y)
# layout
plot(x,y, layout = (4,1), color = [:red,:blue])

What I expected was a coloring of each plot with either red or blue. The result was 4 plots that had both red and blue. What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不语却知心 2025-01-23 08:04:41

这是由于 color 的维度:

julia> [:red,:blue]
2-element Vector{Symbol}:
 :red
 :blue

有理由认为它将将此方案应用于原始数组的每 2 项。但是...

julia> [:red :blue]
1×2 Matrix{Symbol}:
 :red  :blue

这将每两列应用一次。所以应该是这样的:

julia> plot(x, y, layout=(4, 1), color=[:red :blue])

It is due to the dimension of color:

julia> [:red,:blue]
2-element Vector{Symbol}:
 :red
 :blue

It is reasonable to think it will apply this scheme to each 2 items of the original array. However...

julia> [:red :blue]
1×2 Matrix{Symbol}:
 :red  :blue

this will be applied each 2 columns. So it should be as follows:

julia> plot(x, y, layout=(4, 1), color=[:red :blue])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文