JuliaPlots/Plots.jl

aspect_ratio not working expectedly with PGFPlotsX

Open

#4 766 ouverte le 8 juin 2023

Voir sur GitHub
 (3 commentaires) (0 réactions) (0 assignés)Julia (381 forks)batch import
PGFPlotsXbuggood first issue

Métriques du dépôt

Stars
 (1 943 stars)
Métriques de merge PR
 (Merge moyen 13j 6h) (2 PRs mergées en 30 j)

Description

Details

When plotting heatmap with PGFPlotsX backend, I want to have aspect_ratio = 1. The following script

using Plots
pgfplotsx()

heatmap([1, 2, 3, 4], [1, 2, 3, 4], [1 2 1 0 ; 1  3 4 5; 1 0 0 1; 1 9 0 8], aspect_ratio = :equal)  

gives the following figure: The x axis of this plot is of course too wide; but then, the following script aimed to solve the problem by fixing the x range eliminates the effect of aspect_ratio = :equal:

using Plots
pgfplotsx()

heatmap([1, 2, 3, 4], [1, 2, 3, 4], [1 2 1 0 ; 1  3 4 5; 1 0 0 1; 1 9 0 8], 
aspect_ratio = :equal, xlim=(0.5, 4.5))

By inspecting the LaTeX code generated, the problem seems to be that heatmap, when asked to generate a figure with aspect_ratio = :equal, simply adjusts the scale of the x axis so that the main body of the heatmap becomes a square; but this is not what is intuitively expected: there is an axis equal image option for the axis environment in tikz, and, IMHO, this is what should be invoked when the aspect_ratio = :equal option is used.

Backends

This bug occurs on ( insert x below )

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

Versions

Plots.jl version: [91a5bcdd] Plots v1.36.1 Backend version (]st -m <backend(s)>): [8314cec4] PGFPlotsX v1.5.1 Output of versioninfo():

Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, tigerlake)

Guide contributeur