TernaryPlots.jl icon indicating copy to clipboard operation
TernaryPlots.jl copied to clipboard

Problem running the reference example

Open tduretz opened this issue 4 years ago • 10 comments

Hi guys, Thanks for developing this nice package, which I intend to use in my teaching. Unfortunately, I've not yet managed to run the example from your README. Here's how it looks: Screen Shot 2021-10-05 at 5 40 56 PM I'm running in Julia 1.6 in VScode. I get the same results in both standard and notebook (IJulia) modes. Any idea of what's going on? Cheers!

tduretz avatar Oct 05 '21 15:10 tduretz

Hi, thanks for submitting a bug report.

I'm not able to recreate this bug, so some more info would be helpful. Could you check which version of TernaryPlots.jl you are using by running import Pkg; Pkg.status("TernaryPlots")? Also, which OS are you using?

It might be some missing dependencies with the GR backend, so could you try using a different backend for Plots.jl? If you replace the first few lines of the example code with these lines, that should use the PlotlyJS backend. You'll get some warnings about arrows that you can ignore.

using PlotlyJS
using Plots
plotlyjs(size=(900, 600))
Plots.PlotlyJSBackend()
using TernaryPlots
using CSV
using DataFrames

Let me know what that does to the example. Thank you!

Hasnep avatar Oct 05 '21 18:10 Hasnep

Here's for the version of TernaryPlots:

julia> Pkg.status("TernaryPlots")
      Status `~/.julia/environments/v1.6/Project.toml`
  [1f5e811d] TernaryPlots v0.1.0

And the OS is 10.14.3 (Mac OS Mojave).

I've tried with PlotLyJS, the way you suggested, but there seem to be some deeply rooted incompatibility between the different visualisation packages (error trace below, freaky :D) I will now try on a different computer/OS, see if I get it to run on another system.

Cheers

ERROR: MethodError: Cannot `convert` an object of type Tuple{String, Float64} to an object of type AbstractString
Closest candidates are:
  convert(::Type{T}, ::T) where T<:AbstractString at strings/basic.jl:231
  convert(::Type{T}, ::AbstractString) where T<:AbstractString at strings/basic.jl:232
  convert(::Type{T}, ::T) where T at essentials.jl:205
Stacktrace:
  [1] Plots.PlotText(str::Tuple{String, Float64}, font::Plots.Font)
    @ Plots ~/.julia/packages/Plots/Awg62/src/components.jl:370
  [2] plotly_layout(plt::Plots.Plot{Plots.PlotlyJSBackend})
    @ Plots ~/.julia/packages/Plots/Awg62/src/backends/plotly.jl:295
  [3] plotly_show_js(io::IOBuffer, plot::Plots.Plot{Plots.PlotlyJSBackend})
    @ Plots ~/.julia/packages/Plots/Awg62/src/backends/plotly.jl:975
  [4] display(d::VSCodeServer.InlineDisplay, m::MIME{Symbol("application/vnd.plotly.v1+json")}, x::Plots.Plot{Plots.PlotlyJSBackend})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/display.jl:0
  [5] display(d::VSCodeServer.InlineDisplay, mime::String, x::Any)
    @ Base.Multimedia ./multimedia.jl:216
  [6] display(d::VSCodeServer.InlineDisplay, x::Plots.Plot{Plots.PlotlyJSBackend})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/display.jl:152
  [7] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
  [8] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
  [9] invokelatest
    @ ./essentials.jl:706 [inlined]
 [10] (::VSCodeServer.var"#58#62"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/eval.jl:172
 [11] withpath(f::VSCodeServer.var"#58#62"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/repl.jl:185
 [12] (::VSCodeServer.var"#57#61"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/eval.jl:151
 [13] hideprompt(f::VSCodeServer.var"#57#61"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/repl.jl:36
 [14] (::VSCodeServer.var"#56#60"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/eval.jl:122
 [15] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:491
 [16] with_logger
    @ ./logging.jl:603 [inlined]
 [17] (::VSCodeServer.var"#55#59"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/eval.jl:197
 [18] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
 [19] invokelatest(::Any)
    @ Base ./essentials.jl:706
 [20] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [21] (::VSCodeServer.var"#53#54")()
    @ VSCodeServer ./task.jl:411

EDIT: It works on my desktop which OS 10.14.6 and same version of TernaryPlots. I probably have to anyway update my lappy. I will test it soon on many computers... let's see :D

tduretz avatar Oct 06 '21 06:10 tduretz

It now also works on my lappy with updating all packages. I will close the issue. Thanks for developping this cool package!

tduretz avatar Oct 17 '21 08:10 tduretz

Hi, I'm having the same issue on my laptop which is mac OS 10.15.3. I run the code as shown above and get the exact same plot...

pw0908 avatar Nov 02 '21 06:11 pw0908

Hi @pw0908, do you have the same problem running a simpler example, like the following one?

# Generate test data
test_data = rand(100, 3) |> eachrow .|> r -> r ./ sum(r) |> tern2cart

# Plot the data
p = ternary_axes(title = "Rocks", xguide = "SiO2", yguide = "Al2O3", zguide = "MgO")
scatter!(p, getindex.(test_data, 1), getindex.(test_data, 2), legend = false)

I've just run it using MacOS 11.6.1 and it seems to work for me. It might be a problem with some system dependency. :/

Hasnep avatar Nov 02 '21 17:11 Hasnep

This is what I get: Screenshot 2021-11-02 at 10 35 28

pw0908 avatar Nov 02 '21 17:11 pw0908

The change that I think is causing this is the one made when I removed Plots as a dependency by replacing Plots.text("words") with a tuple (i.e.("words")) in all places. Of course, I am not sure what the implications of this are but perhaps updating everything would help as it did before.

jacobusmmsmit avatar Nov 03 '21 15:11 jacobusmmsmit

Where in the code can I replace this?

pw0908 avatar Nov 03 '21 19:11 pw0908

It may just be easier to look at an older version of this package (before the "removed Plots as a dependancy" commit) and ctrl-shift-f (in VSCode) for Plots.text to find every mention. That said I really do have no idea what is causing this and I'm afraid I don't have time to look into it right now.

jacobusmmsmit avatar Nov 12 '21 23:11 jacobusmmsmit

No worries! Thanks a lot for your help! I'll let you know if I manage to find what's responsible!

pw0908 avatar Nov 13 '21 20:11 pw0908