在 Julia 中使用 unicodeplots()

问题描述 投票:0回答:2

我正在尝试使用 unicodeplots() 在 Julia 中生成绘图。 我的第一个版本的代码是

using Plots
unicodeplots()
plt = plot(x,y) #x,y are same length of vectors
display(plt)

我得到的是

   Warning: Error requiring `UnicodePlots` from `Plots`
 exception = (LoadError("/Users/.julia/packages/Plots/gzYVM/src/backends/unicodeplots.jl", 276, LoadError("/Usersg/.julia/packages/Plots/gzYVM/src/backends/unicodeplots.jl", 314, UndefVarError(:FileIO))), Union{Ptr{Nothing}, Base.InterpreterIP}[Ptr{Nothing} @0x0000000105799b1f, Ptr{Nothing} @0x00000001057c80d3, Ptr{Nothing} @0x00000001057e41a3, Ptr{Nothing} @0x00000001057e3083, Ptr{Nothing} @0x00000001057b9fdb, Ptr{Nothing} @0x00000001057b7577, Ptr{Nothing} @0x00000001057b74df, Ptr{Nothing} @0x00000001057b74df, Ptr{Nothing} @0x00000001057b74df, Ptr{Nothing} @0x00000001057b74df, Ptr{Nothing} @0x00000001057b74df, Ptr{Nothing} @0x00000001057b74df, Ptr{Nothing} @0x00000001057b74df, Ptr{Nothing} @0x00000001057b7deb, Ptr{Nothing} @0x00000001057e35d7, Ptr{Nothing} @0x00000001057e414b, Ptr{Nothing} @0x00000001057e4eef, Ptr{Nothing} @0x000000011d5968e7, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x000000016d6c0377, Ptr{Nothing} @0x000000016d6cc01b, Ptr{Nothing} @0x000000016d6cc077, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057bcd17, Ptr{Nothing} @0x000000016bf000cb, Ptr{Nothing} @0x000000016bf00143, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057ca21b, Ptr{Nothing} @0x00000001057c8a03, Ptr{Nothing} @0x00000001057c9053, Base.InterpreterIP in top-level CodeInfo for Plots at statement 8, Ptr{Nothing} @0x00000001057e427f, Ptr{Nothing} @0x00000001057e4eef, Ptr{Nothing} @0x000000016bef407f, Ptr{Nothing} @0x000000016bef409f, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x0000000128fb478b, Ptr{Nothing} @0x000000016bee807b, Ptr{Nothing} @0x000000016bee808f, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057ca21b, Ptr{Nothing} @0x00000001057c8767, Ptr{Nothing} @0x00000001057c8c8b, Ptr{Nothing} @0x00000001057c8403, Base.InterpreterIP in MethodInstance for Requires.withpath(::Any, ::String) at statement 10, Ptr{Nothing} @0x000000016bedc097, Ptr{Nothing} @0x000000016bedc12b, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057bcd17, Ptr{Nothing} @0x000000016bed0073, Ptr{Nothing} @0x000000016bed00fb, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057ca21b, Ptr{Nothing} @0x00000001057c8a03, Ptr{Nothing} @0x00000001057c8403, Base.InterpreterIP in MethodInstance for Requires.loadpkg(::Base.PkgId) at statement 6, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057bcd17, Ptr{Nothing} @0x0000000107bb0433, Ptr{Nothing} @0x000000016bc940d7, Ptr{Nothing} @0x000000016be8839b, Ptr{Nothing} @0x000000016be88837, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057e49f3, Ptr{Nothing} @0x00000001057e3f03, Ptr{Nothing} @0x00000001057c892b, Ptr{Nothing} @0x00000001057c9053, Base.InterpreterIP in top-level CodeInfo for Main at statement 0, Ptr{Nothing} @0x00000001057e427f, Ptr{Nothing} @0x00000001057e4eef, Ptr{Nothing} @0x000000016be641db, Ptr{Nothing} @0x000000016be70143, Ptr{Nothing} @0x000000016be7c00f, Ptr{Nothing} @0x000000016be7c01f, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057ca21b, Ptr{Nothing} @0x00000001057c8a03, Ptr{Nothing} @0x00000001057c9053, Base.InterpreterIP in top-level CodeInfo for Main at statement 0, Ptr{Nothing} @0x00000001057e427f, Ptr{Nothing} @0x00000001057e414b, Ptr{Nothing} @0x00000001057e4eef, Ptr{Nothing} @0x000000011a77026b, Ptr{Nothing} @0x000000011a77c043, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x000000016be45167, Ptr{Nothing} @0x000000016be45eaf, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057bcd17, Ptr{Nothing} @0x000000011a4a0443, Ptr{Nothing} @0x000000011a4b8067, Ptr{Nothing} @0x000000011a4b8073, Ptr{Nothing} @0x00000001057afc63, Ptr{Nothing} @0x00000001057ce9cb])
    └ @ Requires /Users/.julia/packages/Requires/Z8rfN/src/require.jl:51

我只能得到 Plots.UnicodePlotsBackend()

我的第二个版本的代码是

using Plots
using unicodeplots
unicodeplots()
plt = plot(x,y) #x,y are same length of vectors
display(plt)

我得到的是警告:使用 UnicodePlots.xlabel!模块 Main 与现有标识符冲突。

我仍然得到了 Plots.UnicodePlotsBackend()

我的代码可能存在什么问题?

plot julia
2个回答
1
投票

我有几个想法。

  1. 通常当你得到
    Warning:... in Module Main conflicts...
    时,意味着有两个包具有相同的函数名称。例如,您可能加载了 Gadfly(或另一个具有
    plot()
    功能的绘图包)。

有时有效的一件事是在函数之前使用包的名称,中间有一个

.
。例如,我可能会写
Plots.plot
Gadfly.plot

老实说,可能只加载一个绘图包就可以解决您的所有问题。 Jupyter Notebook 不应该是问题,但如果您担心在期望绘图的单元格中丢失输出(只能看到后端输出而不是绘图),只需拆分绘图命令和

using
 unicodeplots()
命令进入不同的单元格。

  1. 没有名为 unicodeplots 的包。然而,有一种叫做 UnicodePlots。我发现它效果很好。如果您无法使用 Plots.jl 的版本,请尝试一下。它确实是为 REPL 制作的,而且很酷,因为我不认为其他绘图包可以让你从那里绘图。

0
投票

我需要安装 UnicodePlots。 也许,它有帮助。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.