Psxy [ERROR]: Found no history for option -J

Hi, and thanks again Joaquim.

I have now finally managed to establish a proper setup for my linux machine, but not without a LOT of investigation, trial and error and of course YOUR very helpful guiding. Therfore I think it may be helpful to you and also others experiencing similar challanges in the linux installation that I share my setup. Please note that my experience is done in a pure linux environment and that other challenges may occur if GMT is installed under e.g. a Conda environment.

My GMT/Julia folder locations are set by the installation of the respective modules which you have pointed to in earlier posts.

  • Folder with GMT v. 6.x.x installation: /home/fg/GMT/
  • Folder with GMT.jl wrapper installation: /home/fg/gmt/
  • Folder with Julia installation: /home/fg/julia/

Added the following lines to my .bshrc file:
export PATH="$PATH:$HOME/GMT/bin"
export PATH="$PATH:$HOME/gmt/bin"
export PATH="$PATH:$HOME/julia/bin"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/fg/GMT/lib/

Create startup.jl file AND “config” folder -> /home/fg/.julia/config/startup.jl
where startup.jl contains the following two lines (pointing to the libgmt.so file):
using Libdl
push!(Libdl.DL_LOAD_PATH, “/home/fg/GMT/lib”)

Prepare JuliaCall and GMT within RStudio:
Install JuliaCall package (a one-timer):
> install.packages(“JuliaCall”)
activate JuliaCall library with it’s embedded functions
> library(JuliaCall)
Run Julia setup command (a one-timer):
> julia <- julia_setup()
Install GMT package within R Julia env. (a one-timer):
> julia_install_package(“GMT”)
Activate GMT library with it’s embedded functions:
> julia_library(“GMT”)

There are now at least six (!) different optional ways for me of running GMT commands, 2 in the ordinary linux terminal window (1) Classic mode input as given in the manuals and (2) Modern mode by first starting julia, and 4 others within RStudio:

(3) Start a “Julia console” (within RStudio Console window). Part of JuliaCall package and the “libray(JuliaCall)” command must be run at startup of session.
> julia_console()
A simple Julia console is started -> GMT testplot:
julia> plot(rand(10), show=true)

(4) Run GMT modern commands directly in the RStudio console using “julia_command()”. Part of JuliaCall package and the “libray(JuliaCall)” command must be run first. -> GMT testplot:
> julia_command(“plot(rand(10), show=true);”)

(5) Run GMT classic commands in the RStudio console using RStudio base “system()” command:
> system(“gmt pscoast -R-180/180/-90/90 -Dc -W -M > world_crude.txt”)

(6) Run GMT modern commands directly in the RStudio terminal window by first starting Julia:
$ julia
julia> using GMT
-> GMT testplot:
julia> plot(rand(10), show=true)

Hope this may be helpful for others!

Nice it works for you too. Yep, linux <==> suffering
I don’t think you need the second of the exports above. Your GMT is under $HOME/GMT/bin. The other one I don’t know what it is.

Also, here I don’t think you need both. I installed Julia on WSL and since I’m using there a custom GMT installation I initially also had the error of not finding libgmt.so But the Libdl setting alone was enough to make it work.

Regarding your now excess of options to run GMT, well they aren’t all equal. Using system calls in R means that you must save the data in disk before being able to use it GMT, whilst the via-Juia way lets you use the in-memory data. This is a BIG difference.

One last thing, does the julia_command(“plot(rand(10), show=true);”) in R automatically displays the plot or it errors like on Windows R?

Hi again Joaquim,

  1. Yes, you are right regarding the

export PATH=“$PATH:$HOME/gmt/bin”

as long as this bin-folder simply is not there :slight_smile: .

2a. Removing the startup.jl file and keeping

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/fg/GMT/lib/

give me error message in RStudio:

julia_install_package(“GMT”)
Error in if (is.na(a)) return(-1L) : argument is of length zero

2b. Keeping the startup.jl file and removing the .bashrc line:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/fg/GMT/lib/

Works for all 4 mentioned GMT command input options in RStudio, so yes you are right also here that I don’t need both - but keeping the startup.jl file is the way to go for me.

  1. Yes, the

julia_command(“plot(rand(10), show=true);”)

will automatically display the plot in my linux RStudio.

Cool. When you have non-trivial examples of using GMT in R you are welcome to post them here.