Skip to content

Commit db61499

Browse files
committed
closes JuliaGraphs#95 (add saveplot)
also uses Reexport to export Measures
1 parent f44fd7b commit db61499

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
1010
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
1111
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1212
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
13+
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
1314
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
15+
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1416
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1517

1618
[compat]
1719
ArnoldiMethod = "0.2"
1820
Colors = "0.12"
1921
Compose = "0.9"
2022
Graphs = "1.4"
23+
Measures = "0.3"
24+
Reexport = "1.2"
2125
julia = "1.6"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ draw(PDF("karate.pdf", 16cm, 16cm), gplot(g))
146146
draw(PNG("karate.png", 16cm, 16cm), gplot(g))
147147
# save to svg
148148
draw(SVG("karate.svg", 16cm, 16cm), gplot(g))
149+
# alternate way of saving to svg without loading Compose
150+
saveplot(gplot(g, plot_size = (16cm, 16cm)), "karate.svg")
149151
```
150152
# Graphs.jl integration
151153
```julia

src/GraphPlot.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module GraphPlot
22

33
using Compose # for plotting features
44
using Graphs
5+
using Reexport
6+
@reexport using Measures
57

68
const gadflyjs = joinpath(dirname(Base.source_path()), "gadfly.js")
79

@@ -15,7 +17,8 @@ export
1517
spring_layout,
1618
spectral_layout,
1719
shell_layout,
18-
stressmajorize_layout
20+
stressmajorize_layout,
21+
saveplot
1922

2023
include("deprecations.jl")
2124

src/plot.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,8 @@ function gplothtml(args...; keyargs...)
333333
close(output)
334334
open_file(filename)
335335
end
336+
337+
function saveplot(gplot::Compose.Context, filename::String)
338+
draw(SVG(filename), gplot)
339+
return nothing
340+
end

0 commit comments

Comments
 (0)