GraphPlot.jl icon indicating copy to clipboard operation
GraphPlot.jl copied to clipboard

WIP: bitmap nodes

Open TeroFrondelius opened this issue 7 years ago • 6 comments

Answering #74

usage example:

logo_urls = [
    "https://github.com/JuliaFEM/JuliaFEM.jl/raw/master/docs/logo/JuliaFEMLogo_96x96.png",
    "https://user-images.githubusercontent.com/25916/36773410-843e61b0-1c7f-11e8-818b-3edb08da8f41.png",
    "http://docs.juliadiffeq.org/v2.0.0/assets/logo.png",
    "https://raw.githubusercontent.com/JuliaLang/IJulia.jl/master/deps/ijulialogo.png"
]

fnames = []
for logo in logo_urls
    fname = tempname()
    push!(fnames,fname)
    download(logo,fname)
end

logos = read.(fnames)

g = SimpleGraph(ones(Int,length(fnames),length(fnames)))

simg = gplot(g, node_bitmap=logos)

image

The current problem is the horizontal light gray line under the logos especially if the logo is transparent like highest one at the above picture.

Another usage example:

logo_name = tempname() * ".png"
# CC BY-SA 3.0 https://commons.wikimedia.org/wiki/File:Personal_Computer_Icon.png
download("https://upload.wikimedia.org/wikipedia/commons/0/06/Personal_Computer_Icon.png",logo_name)
computer_logo = read(logo_name)

g = SimpleGraph(ones(Int,20,20))
gplot(g, node_bitmap=[computer_logo for i in 1:nv(g)])

image

Third example:

# License: Freeware http://www.iconarchive.com/show/karate-icons-by-findhold/karate-flyingkick-icon.html
# License: Freeware http://www.iconarchive.com/show/karate-icons-by-findhold/karate-block-icon.html
karateka = tempname() * ".png"
karateka2 = tempname() * ".png"
download("http://icons.iconarchive.com/icons/findhold/karate/128/karate-flyingkick-icon.png",karateka)
download("http://icons.iconarchive.com/icons/findhold/karate/128/karate-block-icon.png", karateka2)
karateka_pngs = read.([karateka,karateka2])

g = graphfamous("karate")
membership = [1,1,1,1,1,1,1,1,2,1,1,1,1,1,2,2,1,1,2,1,2,1,2,2,2,2,2,2,2,2,2,2,2,2]
pictures = karateka_pngs[membership]
gplot(g, node_bitmap=pictures)

image

TeroFrondelius avatar Nov 26 '18 19:11 TeroFrondelius

Codecov Report

Merging #75 into master will decrease coverage by 31.74%. The diff coverage is 28.57%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #75       +/-   ##
===========================================
- Coverage   48.21%   16.46%   -31.75%     
===========================================
  Files           3        8        +5     
  Lines         168      498      +330     
===========================================
+ Hits           81       82        +1     
- Misses         87      416      +329
Impacted Files Coverage Δ
src/layout.jl 22.07% <0%> (-77.93%) :arrow_down:
src/plot.jl 34.06% <33.33%> (-39.11%) :arrow_down:
src/lines.jl 22.07% <0%> (-8.84%) :arrow_down:
src/pienode.jl 0% <0%> (ø)
src/collapse_plot.jl 0% <0%> (ø)
src/deprecations.jl 0% <0%> (ø)
src/shape.jl 0% <0%> (ø)
src/stress.jl 0% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update adeda23...9130d0d. Read the comment docs.

codecov[bot] avatar Nov 26 '18 19:11 codecov[bot]

That's an interesting addition. Is there a way, that also compose contexts could be used instead of bitmap? (not sure if we would need that though).

I think the problem with the gray line under the transarent logos is, that we currently don't handle self loops correctly.

simonschoelly avatar Dec 23 '18 12:12 simonschoelly

I am not expert on Compose.jl. I wanted to have a plot with logos and made quick and dirty solution. I am willing to finalize it, if you think it's a good addition. Some tests should be added but I don't have an idea how to test it.

Now spending Christmas with my family and left my computer home.

TeroFrondelius avatar Dec 23 '18 13:12 TeroFrondelius

bump @TeroFrondelius, now that two Christmas have passed

matbesancon avatar Jan 22 '20 09:01 matbesancon

If someone wants to finalize this please feel welcome. I don't remember the details anymore and it seems that I won't find time to work on this.

TeroFrondelius avatar Jan 22 '20 10:01 TeroFrondelius

I know it's an old thread, but just wanted to say this feature would be incredibly useful! Busy at the moment, and don't have much programming skills, but maybe in the future I could help look at it. But maybe someone else too!

Garcese avatar Dec 03 '22 23:12 Garcese