Error using UnicodePlots

I got this warning message from “using UnicodePlots” :

WARNING: using UnicodePlots.xlabel! in module Main conflicts with an existing identifier.

And when I do the following code, what can I get is not a real plot:

  unicodeplots()
    plt = plot(x, y)
    display(plt)

It only returns Plot{Plots.UnicodePlotsBackend() n=3}

Is there anyway to get a real plot?

Seems that you are loading more than one plotting package at once (Plots and UnicodePlots). I don’t know where the unicodeplots() command you posted there comes from, but if you really need Plots to be loaded there, then import UnicodePlots instead of using and qualify the function calls:

julia> using Plots # not used here

julia> import UnicodePlots

julia> plt = UnicodePlots.lineplot(rand(10),rand(10))
       ┌────────────────────────────────────────┐ 
   0.9 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢉⠢⢄⠀⠀⠀⠀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢸⡆⠀⠉⠢⢄⠀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⡿⡀⠀⠀⠀⠉⠒⡄⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢇⢣⠀⠀⠀⠀⡜⠀⠀⠀│ 
       │⠢⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢸⠀⢇⠀⠀⡰⠁⠀⠀⠀│ 
       │⠀⣀⣑⠢⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠘⡄⠸⡄⢠⠃⠀⠀⠀⠀│ 
       │⠀⠀⠈⠉⠛⠻⠶⣦⡤⢄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⡇⠀⢱⡇⠀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠉⠫⢖⠚⠭⢕⣒⠢⠤⢄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⢱⠀⡎⢳⡀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠒⢄⡀⠉⠑⠒⠤⢌⣉⠑⠒⠢⠤⢄⣀⡀⡇⠀⠀⢸⡜⠀⠈⣧⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠒⢄⡀⠀⠀⠀⠉⠑⠒⠤⢄⣀⡈⡏⠑⠒⠢⠥⢄⣀⡘⣧⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠒⠤⡀⠀⠀⠀⠀⠀⠀⠈⢹⠒⠢⠤⣀⡀⠀⠈⢹⠃⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠑⠤⡀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠈⠉⠒⠢⠇⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠑⠢⣀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ 
     0 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠺⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ 
       └────────────────────────────────────────┘ 
       ⠀0⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀1⠀ 

julia> display(plt)
       ┌────────────────────────────────────────┐ 
   0.9 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢉⠢⢄⠀⠀⠀⠀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢸⡆⠀⠉⠢⢄⠀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⡿⡀⠀⠀⠀⠉⠒⡄⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢇⢣⠀⠀⠀⠀⡜⠀⠀⠀│ 
       │⠢⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢸⠀⢇⠀⠀⡰⠁⠀⠀⠀│ 
       │⠀⣀⣑⠢⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠘⡄⠸⡄⢠⠃⠀⠀⠀⠀│ 
       │⠀⠀⠈⠉⠛⠻⠶⣦⡤⢄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⡇⠀⢱⡇⠀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠉⠫⢖⠚⠭⢕⣒⠢⠤⢄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⢱⠀⡎⢳⡀⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠒⢄⡀⠉⠑⠒⠤⢌⣉⠑⠒⠢⠤⢄⣀⡀⡇⠀⠀⢸⡜⠀⠈⣧⠀⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠒⢄⡀⠀⠀⠀⠉⠑⠒⠤⢄⣀⡈⡏⠑⠒⠢⠥⢄⣀⡘⣧⠀⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠒⠤⡀⠀⠀⠀⠀⠀⠀⠈⢹⠒⠢⠤⣀⡀⠀⠈⢹⠃⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠑⠤⡀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠈⠉⠒⠢⠇⠀⠀│ 
       │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠑⠢⣀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ 
     0 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠑⠺⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ 
       └────────────────────────────────────────┘ 
       ⠀0⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀1⠀

(you may not need Plots at all there, then just using UnicodePlots and the direct calls to its functions should work - but plot is not one of its functions, it is lineplot instead).

I’m trying to reproduce your result, but I got such plot.

Ah, you are using a notebook. Probably then you should not use unicodeplots at all. Just use:

using Plots
plt = plot(rand(10),rand(10))
display(plt)

I have changed it to vscode, but I got new error that “Warning: _display is not defined for this backend.”, do you mind telling me which editor are you using?

This is the command to activate the unicodeplots backend from within Plots.

@JosieG, you don’t need using UnicodePlots if your are using Plots:

using Plots
unicodeplots()
plot(1:2)

should suffice.

For the fonts issue on windows, see GitHub - JuliaPlots/UnicodePlots.jl: Unicode-based scientific plotting for working in the terminal or https://github.com/JuliaPlots/UnicodePlots.jl/search?q=font&type=issues.

If your font doesn’t support braille patterns, you can fallback to using ASCII characters:

using Plots
unicodeplots()
plot(1:2; extra_kwargs=Dict(:subplot=>(; canvas=:dot, border=:ascii)))
plot(1:2, extra_kwargs=Dict(:subplot=>(; canvas=:ascii, border=:ascii)))  # alternative canvas

Thanks for your reply. I have tried

using Plots
unicodeplots()
plot(1:2)

in jupyter notebook, but still got Plot{Plots.UnicodePlotsBackend() n=1}
And I tried it in vscode, then I got Warning: _display is not defined for this backend. And no plot shows up.
Even I tried the code below in vscode

using Plots
unicodeplots()
plot(1:2; extra_kwargs=Dict(:subplot=>(; canvas=:dot, border=:ascii)))
plot(1:2, extra_kwargs=Dict(:subplot=>(; canvas=:ascii, border=:ascii)))  # alternative canvas

I can still only get Warning: _display is not defined for this backend.

Can you try explicitly call display on the plot object ?

using Plots
unicodeplots()
p = plot(1:2);
display(p)
gui(p)  # alternatively

Still warning: Warning: _display is not defined for this backend.