Contour_labels absent when scale=:log10 in GR

I can’t get GR to draw contour_labels when axes are log-scaled:

using Plots
using FileIO

x = 1:0.5:20
y = 1:0.5:10

f(x, y) = (3x + y ^ 2) * abs(sin(x) + cos(y))

pyplot()
p1 = contour(x, y, f, 
  fill=false,
  scale=:identity,
  contour_labels=true, 
  foreground_color=:blue,
  )
p2 = contour(x, y, f, 
  fill=false,
  scale=:log10,
  contour_labels=true, 
  foreground_color=:blue,
  )
p = plot(p1, p2, size=(1200,500), dpi=300,)
savefig(p, "/tmp/contour_pyplot.png")

gr()
p1 = contour(x, y, f, 
  fill=false,
  scale=:identity,
  contour_labels=true, 
  foreground_color=:blue,
  )
p2 = contour(x, y, f, 
  fill=false,
  scale=:log10,
  contour_labels=true, 
  foreground_color=:blue,
  )
p = plot(p1, p2, size=(1200,500), dpi=300,)
savefig(p, "/tmp/contour_gr.png")

p1 = plot(load("/tmp/contour_pyplot.png"), title="pyplot")
p2 = plot(load("/tmp/contour_gr.png"), title="gr")
p = plot(p1,p2, layout=(2,1), size=(1200,1200), dpi=300,)
savefig(p, "/tmp/comparison.png")
return p

This is under Julia 1.7, Plots v1.28.0, PyPlot v2.10.0, GR v0.64.2.

Possibly related to #2430.
contour_labels and scale are individually supported.
It’s possible they are being drawn off-camera, at some non-scaled location; can anyone show me how to inspect the figure properties like you can in Matlab? Any other suggestions or should I file a bug in Plots?

Thanks, Ben

If we try to bypass Plots.jl and use GR, the problem seems to be there too:

using GRUtils
f(x, y) = (3x + y ^ 2) * abs(sin(x) + cos(y))
x, y = 1:0.5:20,  1:0.5:10
contour(x, y, f, colorbar=false, xlog=true, ylog=true)

It might be a case for opening an issue in GR.
Copying @jheinen, to confirm.

I just fixed the problem in the GR development branch. Will tag a new release in the next days …

2 Likes