0

I'm learning Julia by working through Chris Rackauckas' Introduction and I've come across a task that requires me to plot some data. I couldn't manage to get the Plots module to import so I tried a simple test:

using Plots
x = 1:10
y = 0.5*x + 3
plot(x, y)

When I first run this piece of code using the Juno IDE I get an error:

LoadError: LoadError: LoadError: syntax: unhandled expr (error #<julia: Main.Base.MethodError(f=FixedPointNumbers.#floattype(), args=(Main.FixedPointNumbers.FixedPoint{UInt8, 8},))>)
in include_from_node1(::String) at .\loading.jl:488 (repeats 2 times)
in eval(::Module, ::Any) at .\boot.jl:234
in require(::Symbol) at .\loading.jl:415
in include_string(::String, ::String) at .\loading.jl:441
in include_string(::Module, ::String, ::String) at 2

This refers to the using statement in my snippet. This error does not appear when I run from the REPL. The version info is as follows:

Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
System: NT (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.7.1 (ORCJIT, haswell)

I currently have version 0.10.3 of Plots installed.

RHP
  • 103
  • 7
  • You may need to `Pkg.update()` and restart the REPL in order to make sure your packages are up to date. – Chris Rackauckas Feb 02 '17 at 14:48
  • @Chris As this only appears to happen when I run from Juno it could be that they do something like this in the background. – RHP Feb 03 '17 at 07:40

2 Answers2

2

If you provide some version/platform information by sharing the output of versioninfo(), one can help you better.

For instance, the below excerpt

Pkg.add("Plots")
using Plots
plotly() # this backend is installed by default
x = 1:10
y = 0.5*x + 3
plot(x, y)

works well under

Julia Version 0.5.0
Commit 3c9d753* (2016-09-19 18:14 UTC)
Platform Info:
  System: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (NO_LAPACK NO_LAPACKE NO_AFFINITY SANDYBRIDGE)
  LAPACK: liblapack
  LIBM: libm
  LLVM: libLLVM-3.7.1 (ORCJIT, ivybridge)

Maybe you should conisder Pkg.add("PyPlot") or a similar backend, and try it again later?

Arda Aytekin
  • 1,231
  • 14
  • 24
  • Just tried your suggestion and got a similar error for both Plotly and PyPlots. Is the version info satisfactory? – RHP Feb 02 '17 at 14:54
  • @RHP are you using `workspace()` in any part of your code? might be related to [this issue](https://github.com/JuliaPlots/Plots.jl/issues/576), maybe? – Arda Aytekin Feb 02 '17 at 15:35
  • I been experimenting with this a little more and found that the test code works fine in the REPL the problem only exists in Juno IDE. I'll modify my question to reflect this. – RHP Feb 03 '17 at 07:37
  • Worked it out, I needed to add a display command for it to work with Juno's run file command. – RHP Feb 03 '17 at 14:36
2

To work with the Run File command using the Juno package in the Atom IDE the plot has to be assigned to a variable and passed to the display function.

using Plots
pyplot()
x = 1:100
y = 0.5*x + 10
println(y)
graph = plot(x, y)
display(graph)

This will display the graph in Juno's Plots window. In the comments Arda Aytekin suggested that pyplot(display=true) or graph = plot(x, y, display=true) could be used, which leads to the graph displaying in a separate pyplot window.

RHP
  • 103
  • 7
  • you can even have `pyplot(display=true)` to override the default setting. or, `plot(x,y,display=true)`, maybe. please check these options, too, and modify your answer accordingly. Then, please mark your answer as the solution for future reference :) – Arda Aytekin Feb 03 '17 at 15:49