【问题标题】:Heat map in JuliaJulia 中的热图
【发布时间】:2021-09-09 21:00:08
【问题描述】:

我是新用户,不知道如何解决这个错误:

using AbstractGPs
using LinearAlgebra
using Plots
using Random
using PlutoUI

randomseed=42

Random.seed!(randomseed)

X = rand(datapoints) .* 2 .- 1
PES(x)=x^2

plot(-1:0.01:1, PES, label="Underlying potential", xlabel="Position", ylabel="Energy")

Y = PES.(X)

kernelfunction=SEKernel()
Xrange=range(-3,3; length=100)

plot(heatmap(kernelmatrix(kernelfunction, Xrange); yflip=true))

堆栈跟踪:

MethodError: no method matching Val{:heatmap}(::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char, ::Char)

1. apply_recipe(::Dict{Symbol,Any}, ::Type{Val{:heatmap}}, ::Plots.Plot{Plots.GRBackend})@recipes.jl:49
2. _process_plotrecipe(::Any, ::Any, ::Any, ::Any)@plot_recipe.jl:32
3. _process_plotrecipes!(::Any, ::Any)@plot_recipe.jl:18
4. recipe_pipeline!(::Any, ::Any, ::Any)@RecipesPipeline.jl:81
5. _plot!(::Plots.Plot, ::Any, ::Any)@plot.jl:208
6. #plot#154@plot.jl:91[inlined]
7. #heatmap#406(::Any, ::typeof(Plots.heatmap), ::Any)@RecipesBase.jl:404
8. top-level scope@Local: 2[inlined]

【问题讨论】:

  • 如果可能的话,您能否显示一些代码,以便我们知道导致问题的原因?
  • 好的,谢谢! @logankilpatrick using AbstractGPs using LinearAlgebra using Plots using Random using PlutoUI randomseed=42 Random.seed!(randomseed) X = rand(datapoints) .* 2 .- 1 PES(r)=r^2 plot(-1:0.01:1, PES, label="Underlying potential", xlabel="Position", ylabel="Energy") Y = PES.(X) kernelfunction=SEKernel() Xrange=range(-3,3; length=100) plot(heatmap(kernelmatrix(kernelfunction, Xrange); yflip=true))
  • 您可以编辑原始帖子以包含它吗?

标签: julia


【解决方案1】:

不知道你做错了什么,但这个

using AbstractGPs, LinearAlgebra, Plots, Random # removed PlutoUI

randomseed = 42
Random.seed!(randomseed)

datapoints = 100 # Added for code to be self-contained

X = rand(datapoints) .* 2 .- 1
PES(r) = r^2

# removed first plot

Y = PES.(X)
kernelfunction = SEKernel()
Xrange = range(-3, 3; length=100)

heatmap(kernelmatrix(kernelfunction, Xrange); yflip=true) # removed unnecessary call to `plot`

给我

【讨论】:

  • 感谢大家的帮助
  • 不用担心。您能否按照洛根评论中的要求编辑您的帖子?
猜你喜欢
  • 1970-01-01
  • 2016-02-24
  • 1970-01-01
  • 1970-01-01
  • 2021-02-10
  • 2013-07-29
  • 2019-05-21
  • 2019-06-23
相关资源
最近更新 更多