1
coordinate_distance(x,z) = abs.(x .- z)

square1(x) = sum(coordinate_distance(x,z).^2)

using Plots

LB,UB = 0,20 # Defining Lowerboud and Upperbound

plot(square1, LB, UB, legend=false)

scatter!(z, [square1(x) for x in z])

square1-自定义函数

z-整数数组

错误信息:

MethodError: 没有方法匹配 Val{:scatter}(::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char , ::字符, ::字符, ::字符, ::字符, ::字符, ::字符, ::字符, ::字符, ::字符, ::字符, ::字符, ::字符, : :Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char , ::字符)

Stacktrace:

[1] apply_recipe(plotattributes::Dict{Symbol, Any}, #unused#::Type{Val{:scatter}}, plt::Plots.Plot{Plots.GRBackend})
@ Plots C:\Users\pradnk\.julia\packages\Plots\HcxwM\src\recipes.jl:49
[2] _process_plotrecipe(plt::Any, kw::Any, kw_list::Any, still_to_process::Any)
@ RecipesPipeline 
C:\Users\pradnk\.julia\packages\RecipesPipeline\3x4B9\src\plot_recipe.jl:32
[3] _process_plotrecipes!(plt::Any, kw_list::Any)
@ RecipesPipeline 
C:\Users\pradnk\.julia\packages\RecipesPipeline\3x4B9\src\plot_recipe.jl:18
[4] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline C:\Users\pradnk\.julia\packages\RecipesPipeline\3x4B9\src\RecipesPipeline.jl:81
[5] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
@ Plots C:\Users\pradnk\.julia\packages\Plots\HcxwM\src\plot.jl:208
[6] #plot#154
@ C:\Users\pradnk\.julia\packages\Plots\HcxwM\src\plot.jl:91 [inlined]
[7] scatter(::Any, ::Vararg{Any, N} where N; kw::Any)
@ Plots C:\Users\pradnk\.julia\packages\RecipesBase\3fzVq\src\RecipesBase.jl:404
[8] top-level scope
@ In[10]:2
[9] eval
@ .\boot.jl:360 [inlined]
[10] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base .\loading.jl:1116

我是 Julia 的新手,我以前从未遇到过这个错误。

4

0 回答 0