Skip to content

Scaling of legends when composing plots into layout, v1.25 #4092

@mcabbott

Description

@mcabbott

Something has changed with the scaling of subplots within a layout, which causes the legend to become very wide.

Previously, they retained the size they had within individual plots. Now, the legend within one subplot seems to depend on the size of the overall layout. Especially for scatter plots, this causes the point to be marooned out in space, far from the label. Nothing else (that I know of) scales like this -- other features of a plot remain the same when it is placed into a layout.

Example:

julia> using Plots  # with GR default

julia> p1 = plot(cumsum(rand(30, 5), dims=1); size=(300,400)) # normal short legend lines

julia> plot(p1, p1, p1, p1; size=(1200, 400), layout=(1,4))  # much longer lines in legend

julia> plot!(title="Plots v1.25.7")

legend_125

legend_124

Individual plots do not seem to be as strongly affected:

scatter300_25

scatter300_24

[Edit - subplot sizes corrected so that they are exactly a multiple of the layout size.]

Details

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) X
pyplot X
plotlyjs X
pgfplotsx X
unicodeplots X
inspectdr X
gaston X

Versions

(jl_A9O98Y) pkg> st
Status `/private/var/folders/yq/4p2zwd614y59gszh7y9ypyhh0000gn/T/jl_A9O98Y/Project.toml`
  [28b8d3ca] GR v0.63.1
  [58dd65bb] Plotly v0.4.1
  [a03496cd] PlotlyBase v0.8.18
  [91a5bcdd] Plots v1.25.7

julia> versioninfo()
Julia Version 1.8.0-DEV.1440
Commit e3b681c687 (2022-02-02 01:39 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.1.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.0 (ORCJIT, cyclone)
Environment:
  JULIA_NUM_THREADS = 4

julia> versioninfo()  # same results with rosetta & Julia 1.7
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.5.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, westmere)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions