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

[BUG] Plots.spy with unicodeplots() backend works differently than UnicodePlots.spy #5049

Open
ajinkya-k opened this issue Mar 3, 2025 · 1 comment

Comments

@ajinkya-k
Copy link

Details

Plots.spy flips the matrix axes (which is incorrect) and it also appears incorrect, while UnicodePlots.spy produces the correct output, see image below. In the image the UnicodePlots.spy output correctly represents the underlying matrix. Plots.spy not only flips the output matrix but also introduces more artefacts that shouldn't be there and dont appear in the UnicodePlots.spy call

Image

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pythonplot x
plotlyjs x
pgfplotsx x
unicodeplots x
inspectdr x
gaston x

Versions

Plots.jl version: 1.4.0
Backend version (]st -m <backend(s)>): UnicodePlots v3.7.2
Output of versioninfo():

julia> versioninfo()
Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 11 × Apple M3 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 1 default, 0 interactive, 1 GC (on 5 virtual cores)
Environment:
  DYLD_FALLBACK_LIBRARY_PATH = /Users/ajinkya/.julia/artifacts/9ada70096e6dad3b5cfcb8d97f9aeaef17b5a941/lib/:
@ajinkya-k ajinkya-k added the bug label Mar 3, 2025
@t-bltg t-bltg changed the title [BUG] Plots.spy with unicodelots() backend works differently than UnicodePlots.spy [BUG] Plots.spy with unicodeplots() backend works differently than UnicodePlots.spy Mar 9, 2025
@t-bltg
Copy link
Member

t-bltg commented Mar 22, 2025

Yeah, this is just a convention.

In the image the UnicodePlots.spy output correctly represents the underlying matrix.

There is no "correct" representation, both are acceptable and we had to make some choices. UnicodePlots chooses to remain close to what is displayed in the terminal:

julia> using LinearAlgebra, UnicodePlots
julia> A = Matrix(1I, 4, 4)
4×4 Matrix{Int64}:
 1  0  0  0
 0  1  0  0
 0  0  1  0
 0  0  0  1

julia> spy(A)
     ┌─────┐    
   1 │⠁⠂⡀⠀⠀│ > 0
   4 │⠀⠀⠀⠁⠀│ < 0
     └─────┘    
     ⠀1⠀⠀⠀4⠀    
     ⠀4  0

There is a similar discussion for heatmaps (image convention opposed to matrix convention).

The artefacts are related to the unicode pixel size, and are expected, since a line is usually "staircased" (stair-step effect) when using low resolution terminal characters.

I won't be opposed to changing the convention in Plots v2, as it is more consistent with a matrix representation either in the terminal or on paper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants