Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cornerplot fails with Boston Housing dataset #1333

Closed
smartinsightsfromdata opened this issue Dec 23, 2023 · 2 comments
Closed

cornerplot fails with Boston Housing dataset #1333

smartinsightsfromdata opened this issue Dec 23, 2023 · 2 comments

Comments

@smartinsightsfromdata
Copy link

I'm trying to plot a correlogram, like R and Python. But a simple dataset like Boston Housing creates problems.
This is my code:

using GMT, DataFrames
using MLDatasets: BostonHousing
dataset = BostonHousing()
df = dataset.features;
M = Matrix(df[:, 1:end-1])
cornerplot(M, scatter=true, marker=:dot, mec=:blue, ms="3p", show=true)

The above fails with this error:

histogram [WARNING]: Cannot tell if -T1 -W0.1 is new or deprecated syntax; selected deprecated.
histogram [ERROR]: Unrecognized option -T
Something went wrong when calling the module. GMT error number = 72

Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] gmt(::String, ::Vector{Float64}, ::Vararg{Any})
   @ GMT ~/.julia/packages/GMT/OueOM/src/gmt_main.jl:163
 [3] finish_PS_module(::Dict{Symbol, Any}, ::Vector{String}, ::String, ::Bool, ::Bool, ::Bool, ::Vector{Float64}, ::Vararg{Any})
   @ GMT ~/.julia/packages/GMT/OueOM/src/common_options.jl:4252
 [4] histogram_helper(cmd0::String, arg1::Vector{Float64}; first::Bool, kwargs::Base.Pairs{Symbol, Any, NTuple{7, Symbol}, NamedTuple{(:conf, :B, :R, :G, :W, :panel, :Vd), Tuple{NamedTuple{(:MAP_FRAME_TYPE,), Tuple{String}}, String, String, String, Float64, Tuple{Int64, Int64}, Int64}}})
   @ GMT ~/.julia/packages/GMT/OueOM/src/pshistogram.jl:251
 [5] histogram_helper
   @ ~/.julia/packages/GMT/OueOM/src/pshistogram.jl:94 [inlined]
 [6] #histogram#700
   @ ~/.julia/packages/GMT/OueOM/src/pshistogram.jl:89 [inlined]
 [7] cornerplot(arg1::Matrix{Float64}; first::Bool, kwargs::Base.Pairs{Symbol, Any, NTuple{5, Symbol}, NamedTuple{(:scatter, :marker, :mec, :ms, :show), Tuple{Bool, Symbol, Symbol, String, Bool}}})
   @ GMT ~/.julia/packages/GMT/OueOM/src/statplots.jl:1267
 [8] top-level scope
   @ In[5]:1

The odd thing is that I am successful calling the same function to plot the IRIS dataset:

using GMT, DataFrames
using RDatasets: dataset
iris = dataset("datasets", "iris")
M = Matrix(iris[:, 1:end-1])   # leaving out :Species (type string)
cornerplot(M, scatter=true, marker=:dot, mec=:blue, ms="3p", show=true)

Clearly the size of the Boston Housing dataset is the problem, but I would expect to use these functions with much larger datasets (like I do with R or Python).

The above has been tested on ubntu 23.04 Julia 1.9.4 and jupyterlab.

@joa-quim
Copy link
Member

Hi, if you update to GMT.jl version 1.9.2 you can now do cornerplot(df, ... but mind you that this works only for simple numeric DataFrames. You can also do D = mat2ds(df) and get a GMTdataset that is more appropriate to use in GMT.jl.

Regarding the display or not display in Notebooks, I though I had fixed most of it in recent versions. It does work (I think) for me in VSC Jupyter Nootebooks, but for using it there one must set ENV["DISPLAY_IN_VSC"] = "whatever";
The root thing is that GMT (the C lib) has two modes; the classic, where the files are written in current directory or any other using the redirect > operator and a modern mode where everything happens in sessions hidden directory. GMT.jl uses mostly the classic mode but things like statsplots functions that use the subplot module have to use the modern mode. Due to this the way figures are displayed changes slightly and it used to fail in-Notebook display, but as I said, I thought I had fixed that. Apparently needs more work.

@joa-quim
Copy link
Member

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants