牛虻地块目前是可组合的吗? [英] Are Gadfly plots currently composable?
问题描述
目前有没有办法在 Gadfly.jl 中添加绘图元素?
Is there currently a way to add plot elements together in Gadfly.jl?
例如,在 R 中,如果我有另一个返回 ggplot 的函数并且我想为其添加标题,我会执行以下操作:
For example, in R if I have another function that returns a ggplot and I want to add a title to it, I'd do the following:
p <- makeMyPlot()
p + ggtitle("Now it has a title")
目前有牛虻等价物吗?如果没有,这是否在 Gadfly 的路线图上?
Is there currently a Gadfly equivalent? If not, is this on Gadfly's roadmap?
推荐答案
有add_plot_element()
,它可以向现有层添加东西:
There is add_plot_element()
, which can add stuff to an existing layer:
xs = [0:0.1:pi]
l = layer(x=xs, y=sin(xs))
add_plot_element(l, Guide.title("Now it has a title"))
然后您可以使用 plot(l)
绘制图层,并调用 draw
或 display
来实际显示某些内容.再往下,还有一堆直接作用于 Plot
的重载:
You can then plot the layer using plot(l)
, and invoke either draw
or display
to actually show something. Further down, there's a bunch of overloads that work on a Plot
directly:
p = plot(x=xs, y=sin(xs))
add_plot_element(p, Guide.title("Now it has a title"))
display(p)
我在文档中找不到这两个函数,但是幸运的是,来源是可以理解的.Julia 的众多乐趣之一 =)
I can't find either of these functions in the documentation, but fortunately the source is comprehensible enough. One of the many joys of Julia =)
这篇关于牛虻地块目前是可组合的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!