Skip to content
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

subplot_grid + titles ? #840

Closed
edljk opened this issue May 11, 2016 · 3 comments
Closed

subplot_grid + titles ? #840

edljk opened this issue May 11, 2016 · 3 comments

Comments

@edljk
Copy link

edljk commented May 11, 2016

Does it exist a way to associate to every plot of a subplot_grid its own title (eventually depending of the dataframe for instance) ?

@Mattriks
Copy link
Member

Mattriks commented May 12, 2016

Maybe:

using RDatasets
data = dataset("datasets", "CO2")
labels=["Title 1", "Title 2", "Title 3","Title 4" ]
titledata = DataFrame(label=labels, x=500, y=58, 
    Type=unique(data[:Type])[[1,2,1,2]],
    Treatment=unique(data[:Treatment])[[1,1,2,2]] )
coord = Coord.cartesian(ymin=0, ymax=60)

p=plot(data, xgroup=:Type, ygroup=:Treatment,
Geom.subplot_grid(coord,
    layer(data, x=:Conc, y=:Uptake,  xgroup=:Type, ygroup=:Treatment, Geom.point),
    layer(titledata, x=:x, y=:y, label=:label, xgroup=:Type, ygroup=:Treatment, Geom.label(position=:centered)),
    Guide.yticks(ticks=collect(0:10:50))
),       
    Guide.title("Title of Plot"),
    Guide.xlabel("Concentration"),
    Guide.ylabel("Uptake")
)

@Mattriks
Copy link
Member

Note that because I have now added data, xgroup=:Type, ygroup=:Treatment in the first line of the plot statement, it is possible to remove these from the first layer:

layer(x=:Conc, y=:Uptake, Geom.point)

for tidier code.

@edljk
Copy link
Author

edljk commented May 12, 2016

Perfect, thank you very much !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants