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

Subplots? #22

Closed
piperod opened this issue Oct 31, 2016 · 7 comments
Closed

Subplots? #22

piperod opened this issue Oct 31, 2016 · 7 comments

Comments

@piperod
Copy link

piperod commented Oct 31, 2016

I would like to create a figure with several graphs. Does GraphPlot support anything like subplot?

@sbromberger
Copy link
Contributor

Not sure what functionality you're looking for, but you might try "combining" the graphs so that they're effectively disconnected components of a larger graph. That is:

julia> g = CompleteGraph(3)
{3, 3} undirected graph

julia> h = PathGraph(4)
{4, 3} undirected graph

julia> j = blkdiag(g,h)
{7, 6} undirected graph

@afternone
Copy link
Contributor

afternone commented Nov 2, 2016

@piperod There is no subplot function in GraphPlot. You can do subplots like this:

using GraphPlot
using Compose
using LightGraphs

g1 = CompleteGraph(10)
g2 = PathGraph(10)
g3 = barabasi_albert(10,3)
g4 = StarGraph(10)

compose(context(),
(context(0, 0, 0.5, 0.5), gplot(g1)),
(context(0.5, 0, 0.5, 0.5), gplot(g2)),
(context(0, 0.5, 0.5, 0.5), gplot(g3)),
(context(0.5, 0.5, 0.5, 0.5), gplot(g4)))

# add titles
compose(context(),
(context(0, 0, 0.5, 0.05), text(0.5,0,"complete graph",hcenter,vtop)),
(context(0, 0.05, 0.5, 0.45), gplot(g1)),
(context(0.5, 0, 0.5, 0.05), text(0.5,0,"path graph",hcenter,vtop)),
(context(0.5, 0.05, 0.5, 0.45), gplot(g2)),
(context(0, 0.5, 0.5, 0.05), text(0.5,0,"scale-free graph",hcenter,vtop)),
(context(0, 0.55, 0.5, 0.45), gplot(g3)),
(context(0.5, 0.5, 0.5, 0.05), text(0.5,0,"star graph",hcenter,vtop)),
(context(0.5, 0.55, 0.5, 0.45), gplot(g4)))

For more information, please refer to Compose.jl

@duodenum96
Copy link

Hello,

Reviving this again; Compose does not support plots generated by plot() function. Is there a way to use Graphplot plot with regular plots in a layout?

Thanks!

@hdavid16
Copy link
Contributor

Have you tried @afternone 's solution?

@duodenum96
Copy link

Yes, but compose doesn't support regular plots generated by for example

p1 = plot(...)

@hdavid16
Copy link
Contributor

Then I believe the answer to your original question is no. You could save your GraphPlot plot to an image file and then try to use it in a subplot in Plots.jl or Makie.jl.

@duodenum96
Copy link

Thanks nonetheless and thanks for the great package!

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

5 participants