-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Titles after vstack/hstack #600
Comments
There's not any special support for this, but it's possible to do "manually" through Compose: p = hstack(plot(x=rand(50), y=rand(50), Geom.point),
plot(x=rand(50), y=rand(50), Geom.point))
title = compose(context(0, 0, 1w, 0.25inch),
text(0.5, 1.0, "These are some plots", hcenter, vbottom))
vstack(title, p) |
Thanks, this is great. I assume I need to add "using Compose" to the top of my code? |
Oh, right. You do need |
is there documentation for the compose() and text() functions somewhere? I didn't see it on composejl.org |
Those are the docs right now, plus the source itself
|
There's unfortunately not API documentation for things like |
What's the best way to handle the case of an odd number of plots? In other words, how would one leave a blank on one side of the "bottom" row? |
FWIW, here is my best shot. I couldn't figure out how to specify font attributes other than family and size. Creating an all white plot is a bit crude, but it does seem to work.
|
That's pretty good. Another way to go about this is with using Gadfly, Compose
M = Array(Compose.Context, (2,2))
M[1,1] = render(plot(x=rand(10), y=rand(10)))
M[1,2] = render(plot(x=rand(10), y=rand(10)))
M[2,1] = render(plot(x=rand(10), y=rand(10)))
M[2,2] = context()
gridstack(M) It might be worth trying to make this sort of thing simpler. |
contex()? Are you kidding me! This is great. The example I came up with reduces to:
For some reason, yesterday vstack was complaining about not accepting a type “Table”. For sure, it is worth making laying out a group of plots easier. What I’d belly up to is building on the MatPlotLib model of declaring grids and then allocating rectangular blocks of the grid either to a single plot or another grid. I could also imagine being able to assign a few parameters to each grid - maybe a title and a border of some sort. The purpose of the grid is to provide a sense of relative size - without the need for relative (i.e. unit) coordinates. I don’t know yet whether it would make sense to finish some of the other work we’ve discussed before diving into something like this which would, admittedly, be fun… Stephen
|
The example by @dcjones (first response) actually cuts of the x labels from the plots. Any idea how to get them showing? |
+1, this shared title solution cuts off the x-axis labels... |
Try relative not absolute sizes (see also #656). using Compose
pa = hstack(plot(x=rand(50), y=rand(50), Geom.point),
plot(x=rand(50), y=rand(50), Geom.point))
title = compose(context(0, 0, 1, 0.1),
text(0.5, 1.0, "These are some plots", hcenter, vbottom))
p = vstack(title, compose(context(0, 0, 1, 0.9), pa)) Note that the output of |
Is it possible to add titles to a grid of figures? Say I've got plots p1-p4, and I combine them and render to a PDF (as in the documentation):
draw(PDF("file.pdf",6inch,6inch),vstack(hstack(p1,p2),hstack(p3,p4))
I see that its possible to add titles to each of the individual plots, but how would I add a title above (or below) the grid of p1-p4?
The text was updated successfully, but these errors were encountered: