Skip to content

Contour labels are erased by axis flipping #2430

@mrkrause

Description

@mrkrause

When using the GR Backend, contour labels are correctly plotted until the axes are flipped. Other axis manipulation (e.g., changing the plot limits, either in the call or via xlims!) seem to leave the labels intact.

Here is an example, generated with Plots v0.28.4, GR v0.44.90, and Julia 1.2.0 (via JuliaPro)

Expected output is that the lower-left and upper-right plots have some contour labels, even if they're not always in exactly the same position. However, they are completely missing instead.
contour_bug_PlotsGR

# Bivariate normal as an example
x = -7:0.05:7
y = x'
z = Matrix{Float64}(undef, length(x), length(y))
@. z = exp(-(x^2 + y^2/6))
levels = [0.0001, 0.01, 0.1]

import Plots
Plots.backend() # GR.backend
p1 = Plots.contour(x,y',z; levels=levels, contour_labels=true, title="No flip")
p2 = Plots.contour(x,y',z; levels=levels, contour_labels=true, title="xflip in call", xflip=true)
p3 = Plots.contour(x,y',z; levels=levels, contour_labels=true, title="Flipped afterward with xflip!")
Plots.xflip!(p3)
p4 = Plots.contour(x,y',z; levels=levels, contour_labels=true, ylims=(-5,5), title="Other axis manipulation")
Plots.xlims!(p4, -8,8)

Plots.plot(p1, p2, p3, p4)
Plots.savefig("/tmp/contour_bug_PlotsGR.png") #Uploaded above

I have not tried this with other backends, since it doesn't run with PyPlot (See #2201 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions