牛ly目前是否可以组合? [英] Are Gadfly plots currently composable?

查看:121
本文介绍了牛ly目前是否可以组合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在有什么方法可以在Gadfly.jl中添加plot元素吗?

例如,在R中,如果我有另一个返回ggplot的函数,并且我想要要添加一个标题,我会做以下事情:

pre $ lt; code> p< - makeMyPlot()
p + ggtitle(现在它有一个标题)

目前有牛ly相当于?如果没有,这是在Gadfly的路线图上吗? add_plot_element() ,它可以添加东西到现有图层:

  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 显示以实际显示某些内容。 进一步向下,有一堆可以直接在 Plot 上工作的重载:

  p = plot(x = xs,y = sin(xs))
add_plot_element(p,Guide.title(Now it has a title))
display(p)

我无法在文档,但幸运的是源代码已经足够理解了。朱莉娅的许多快乐之一=)

Is there currently a way to add plot elements together in Gadfly.jl?

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")

Is there currently a Gadfly equivalent? If not, is this on Gadfly's roadmap?

解决方案

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"))

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)

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 =)

这篇关于牛ly目前是否可以组合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆