Repository navigation
Plot rows of A down the y axis in plot_sparse_matrix() - #75
Draft
alexpghayes wants to merge 1 commit into
Draft
alexpghayes wants to merge 1 commit into
alexpghayes wants to merge 1 commit into
Conversation
plot_sparse_matrix() mapped row index i to the x axis, so it was the transpose of plot_dense_matrix(), which puts columns on the x axis and rows down the (reversed) y axis. The difference only shows for asymmetric matrices, e.g. directed or rectangular graphs. Map x = j, y = i, and swap the expand_limits() arguments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
plot_sparse_matrix()usedaes(x = i, y = j)(R/plotting.R:83), which puts rowion the x axis.plot_dense_matrix()(and soplot_expectation()) usesaes(x = col, y = row)with a reversed y axis, the usual matrix layout. So the sparse plot was the transpose of the dense one. The difference only shows for asymmetric matrices, i.e. directed or rectangular graphs.Fix
aes(x = j, y = i), with theexpand_limits()arguments swapped to match.Tests
New
tests/testthat/test-plotting.R: a 2 × 4 matrix with one entry at row 1, column 3 is drawn at x = 3, y = -1 (reversed axis) by bothplot_sparse_matrix()andplot_dense_matrix(). Fails onmain(4 failures), passes here. Full suite passes. Noman/changes.Note for the
docs/blockmodel-vignettedraftThe draft vignette works around this in
vignettes/blockmodels.Rmd(around line 731) withplot_sparse_matrix(t(A_dd))and a comment explaining the transpose. Once this is merged, that chunk should be plainplot_sparse_matrix(A_dd), without the comment. I haven't touched that branch.NEWS
Left out to avoid conflicting with #59. Suggested bullet under Bug fixes:
🤖 Generated with Claude Code