Surface command in Julia

MethodError: no method matching optimize_ticks(::Float64, ::Float64; k_min=4, k_max=8, scale=:identity)
Closest candidates are:
  optimize_ticks(::T, ::T; extend_ticks, Q, k_min, k_max, k_ideal, granularity_weight, simplicity_weight, coverage_weight, niceness_weight, strict_span, span_buffer) where T at C:\Users\manis\.julia\packages\PlotUtils\es5pb\src\ticks.jl:129 got unsupported keyword argument "scale"

  [1] kwerr(::NamedTuple{(:k_min, :k_max, :scale), Tuple{Int64, Int64, Symbol}}, ::Function, ::Float64, ::Float64)
    @ Base .\error.jl:157
  [2] optimal_ticks_and_labels(ticks::Nothing, alims::Tuple{Float64, Float64}, scale::Symbol, formatter::Symbol)
    @ Plots ~\.julia\packages\Plots\G6ceC\src\axes.jl:172
  [3] get_ticks(::Symbol, ::Vector{Float64}, ::Vector{Any}, ::Tuple{Float64, Float64}, ::Vararg{Any, N} where N)
    @ Plots ~\.julia\packages\Plots\G6ceC\src\axes.jl:313
  [4] get_ticks(sp::Plots.Subplot{Plots.GRBackend}, axis::Plots.Axis; update::Bool)
    @ Plots ~\.julia\packages\Plots\G6ceC\src\axes.jl:234
  [5] get_ticks
    @ ~\.julia\packages\Plots\G6ceC\src\axes.jl:223 [inlined]
  [6] _update_min_padding!(sp::Plots.Subplot{Plots.GRBackend})
    @ Plots ~\.julia\packages\Plots\G6ceC\src\backends\gr.jl:766
  [7] iterate
    @ .\generator.jl:47 [inlined]
  [8] _collect(c::Matrix{AbstractLayout}, itr::Base.Generator{Matrix{AbstractLayout}, typeof(Plots._update_min_padding!)}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{2})
    @ Base .\array.jl:691
  [9] collect_similar
    @ .\array.jl:606 [inlined]
 [10] map
    @ .\abstractarray.jl:2294 [inlined]
 [11] _update_min_padding!(layout::Plots.GridLayout)
    @ Plots ~\.julia\packages\Plots\G6ceC\src\layouts.jl:282
 [12] prepare_output(plt::Plots.Plot{Plots.GRBackend})
    @ Plots ~\.julia\packages\Plots\G6ceC\src\plot.jl:224
 [13] show(io::IOBuffer, m::MIME{Symbol("image/svg+xml")}, plt::Plots.Plot{Plots.GRBackend})
    @ Plots ~\.julia\packages\Plots\G6ceC\src\output.jl:214
 [14] sprint(::Function, ::MIME{Symbol("image/svg+xml")}, ::Vararg{Any, N} where N; context::Nothing, sizehint::Int64)
    @ Base .\strings\io.jl:105
 [15] sprint
    @ .\strings\io.jl:101 [inlined]
 [16] _ijulia_display_dict(plt::Plots.Plot{Plots.GRBackend})
    @ Plots ~\.julia\packages\Plots\G6ceC\src\ijulia.jl:53
 [17] display_dict(plt::Plots.Plot{Plots.GRBackend})
    @ Plots ~\.julia\packages\Plots\G6ceC\src\init.jl:82
 [18] #invokelatest#2
    @ .\essentials.jl:708 [inlined]
 [19] invokelatest
    @ .\essentials.jl:706 [inlined]
 [20] execute_request(socket::ZMQ.Socket, msg::IJulia.Msg)
    @ IJulia ~\.julia\packages\IJulia\e8kqU\src\execute_request.jl:112
 [21] #invokelatest#2
    @ .\essentials.jl:708 [inlined]
 [22] invokelatest
    @ .\essentials.jl:706 [inlined]
 [23] eventloop(socket::ZMQ.Socket)
    @ IJulia ~\.julia\packages\IJulia\e8kqU\src\eventloop.jl:8
 [24] (::IJulia.var"#15#18")()
    @ IJulia .\task.jl:406

Hello Guys When trying to use “surface” I am getting this error
Please help.It is very urgent
Thanks in Advance

Hello @Manisha_07, this is not the first time members of this forum have asked you to follow the recommended guidelines and post a MWE.

To respect the time of others and increase your chances to get the help requested, please try to do so.


At least for me, the surface command from the Plots package works fine. To find out why it doesn’t work in your case, you should provide more information on what exactly you tried and the packages in your environment, as requested above.

A quick guess though: It seems that you might be using a newer version of Plots together with an older, incompatible version of PlotUtils, have you tried updating the latter?

The questioner must provide all information to reproduce the error, in particular, the minimal working code that can be simply copy-and-pasted and executed.

The following code probably reproduces the error. See Mesh grid in Julia - #3 by genkuroki

using Plots

f(t, x) = exp(-x^2/(2t))/√(2π*t)
u(t, x) = f(t+0.1, x+2) + 2f(t+0.2, x-2)
t = range(0, 3; length=101)
x = range(-5, 5; length=101)
T = u.(t', x)

surface(t, x, T; colorbar=false,
    xlabel="t", ylabel="x", zlabel="T",
    camera=(30, 70), color=reverse(cgrad(:RdYlBu_11)))

The code above works fine in my Windows 10 environment.

Versions of packages:

using Pkg
Pkg.status("PlotUtils"; mode=PKGMODE_MANIFEST)
Pkg.status("GR"; mode=PKGMODE_MANIFEST)
VERSION = v"1.6.2"
      Status `D:\OneDrive\public\0015\Surrogates\Project.toml`
  [91a5bcdd] Plots v1.20.1
      Status `D:\OneDrive\public\0015\Surrogates\Manifest.toml`
  [995b91a9] PlotUtils v1.0.11
      Status `D:\OneDrive\public\0015\Surrogates\Manifest.toml`
  [28b8d3ca] GR v0.58.1

cf. Mesh grid in Julia - #7 by Manisha_07

@Manisha_07 Please run the Pkg status commands in the last reply. Please let us know the results.

1 Like

Thanks for the reply.I used Pkg status commands and it is working

What is the version of PlotUtils.jl you are using?

See the following comments:

Please let us know the results (= outputs).

The optimize_ticks function that gave you the error is defined in PlotUtils.jl/src/ticks.jl.

@Manisha_07 You are supposed to run the command and paste the results into a reply.

Please do the following for us: tell us a bit about yourself and why you are using Julia.
To explain, open source software is a gift economy. People here give help for free, but it is polite to give something in return. That something might be the solution to your problem. It might be helping someone else when you see the same problem. It could be fixing a bug or making an enhancement to Julia. Or it may be telling us how you use Julia.

1 Like