Skip to content

Add package extension for visualization of colorings#149

Merged
gdalle merged 31 commits intoJuliaDiff:mainfrom
adrhill:ah/img-ext
Oct 9, 2024
Merged

Add package extension for visualization of colorings#149
gdalle merged 31 commits intoJuliaDiff:mainfrom
adrhill:ah/img-ext

Conversation

@adrhill
Copy link
Copy Markdown
Contributor

@adrhill adrhill commented Oct 8, 2024

Add an un-exported show_colors function as well as tests and documentation for it.
The function has some options for customization:

    show_colors(result)

Return an image visualizing an [`AbstractColoringResult`](@ref).

!!! warning
    Using this function requires loading [Images.jl](https://github.com/JuliaImages/Images.jl).

## Keyword arguments
* `colorscheme`: colors used for non-zero matrix entries. 
* `background`: color used for zero matrix entries and padding. Defaults to a transparent background.
* `scale::Int`: scale the size of matrix entries to `scale × scale` pixels. Defaults to `1`. 
* `padding::Int`: padding between matrix entries. Defaults to `0`. 
image

Currently the function errors when the matrix-coloring has more colors than the provided colorscheme. I can add some color cycling to circumvent this if desired.

Edit: turned this from an Images.jl extension to a ColorTypes.jl extension to make it more light-weight.

@adrhill
Copy link
Copy Markdown
Contributor Author

adrhill commented Oct 8, 2024

The code is written to make it as easy as possible to extend _show_colors! on future AbstractColoringResult types.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (7146a7d) to head (0cbb367).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #149    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           12        13     +1     
  Lines          884      1010   +126     
==========================================
+ Hits           884      1010   +126     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adrhill adrhill changed the title Add Images.jl extension for visualization of colorings Add package extension for visualization of colorings Oct 8, 2024
Copy link
Copy Markdown
Member

@gdalle gdalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this very pretty contribution!

Comment thread Project.toml Outdated
Comment thread docs/src/vis.md Outdated
Comment thread docs/src/vis.md
Comment thread docs/Project.toml
Comment thread ext/SparseMatrixColoringsColorTypesExt.jl Outdated
Comment thread src/show_colors.jl Outdated
Comment thread ext/SparseMatrixColoringsColorTypesExt.jl Outdated
Comment thread ext/SparseMatrixColoringsColorTypesExt.jl Outdated
Comment thread ext/SparseMatrixColoringsColorTypesExt.jl Outdated
Comment thread ext/SparseMatrixColoringsColorTypesExt.jl Outdated
@adrhill
Copy link
Copy Markdown
Contributor Author

adrhill commented Oct 8, 2024

This is what the new doc page looks like:

Visualization · SparseMatrixColorings.jl.pdf

@adrhill adrhill requested a review from gdalle October 8, 2024 20:29
Comment thread docs/src/vis.md
Comment thread docs/src/vis.md
Copy link
Copy Markdown
Contributor Author

@adrhill adrhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excited for this!

Comment thread ext/SparseMatrixColoringsColorsExt.jl Outdated
Comment thread ext/SparseMatrixColoringsColorsExt.jl Outdated
Comment thread ext/SparseMatrixColoringsColorsExt.jl Outdated
Copy link
Copy Markdown
Member

@gdalle gdalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@gdalle gdalle merged commit 0c18b7b into JuliaDiff:main Oct 9, 2024
@adrhill adrhill deleted the ah/img-ext branch October 9, 2024 11:01
@adrhill
Copy link
Copy Markdown
Contributor Author

adrhill commented Oct 9, 2024

Would be nice to have a release tagged for this! :)

@gdalle
Copy link
Copy Markdown
Member

gdalle commented Oct 9, 2024

#150

@amontoison
Copy link
Copy Markdown
Collaborator

amontoison commented Oct 9, 2024

Thanks @adrhill for working on that!

@adrhill
Copy link
Copy Markdown
Contributor Author

adrhill commented Oct 9, 2024

Check it out in action! :)
https://gdalle.github.io/SparseMatrixColorings.jl/stable/vis/

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

Successfully merging this pull request may close these issues.

3 participants