0

我有一个用滑块创建绘图的函数。该代码基于本 Makie 教程中的第一个示例

function plotLaneEmden(log_delta_xi=-4, n=3)    

    fig = Figure()

    ax = Axis(fig[1, 1])
 
    sl_x = Slider(fig[2, 1], range = 0:0.01:4.99, startvalue = 3)
    sl_y = Slider(fig[1, 2], range = -6:0.01:0.1, horizontal = false, startvalue = -2)

    point = lift(sl_x.value, sl_y.value) do n, log_delta_xi
        Point2f(n, log_delta_xi)
    end

    plot(n,  1 .- log_delta_xi.^2/6,  linecolor = :green, label="n = $n")
    
    xlabel!("ξ")
    ylabel!("θ")

end

我收到错误和警告消息:

WARNING: both GLMakie and Plots export "ylabel!"; uses of it in module Main must be qualified
WARNING: both GLMakie and Plots export "xlabel!"; uses of it in module Main must be qualified
WARNING: both GLMakie and Plots export "plot"; uses of it in module Main must be qualified
UndefVarError: plot not defined

我在这里想念什么?

4

1 回答 1

0

您的代码中有:

using GLMakie 
using Plots 

这会导致两个模块都导出plot命令。在这种情况下,您需要编写:

GLMakie.plot(....)
GLMakie.xlabel!("ξ")

您还可以考虑这样做:

using GLMakie 
import Plots 

在这种情况下,您将不会遇到两个库的命名冲突。您仍然可以Plots通过键入来使用任何方法Plots.methodname(.....)

于 2022-01-08T02:10:04.050 回答