julia> using GR
julia> heatmap([1 2], [3 4], [5 6; 7 8])
ERROR: AssertionError: length(x) == dimx + 1 && length(y) == dimy + 1
Stacktrace:
[1] nonuniformcellarray(::Array{Int64,2}, ::Array{Int64,2}, ::Int64, ::Int64, ::Array{Int64,2}) at C:\Users\aaron\.julia\packages\GR\8mv9N\src\GR.jl:754
[2] plot_data(::Bool) at C:\Users\aaron\.julia\packages\GR\8mv9N\src\jlgr.jl:1306
[3] plot_data at C:\Users\aaron\.julia\packages\GR\8mv9N\src\jlgr.jl:1074 [inlined]
[4] heatmap(::Array{Int64,2}, ::Array{Int64,2}, ::Array{Int64,2}; kv::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\aaron\.julia\packages\GR\8mv9N\src\jlgr.jl:2052
[5] heatmap at C:\Users\aaron\.julia\packages\GR\8mv9N\src\jlgr.jl:2047 [inlined]
[6] #heatmap#17 at C:\Users\aaron\.julia\packages\GR\8mv9N\src\GR.jl:3419 [inlined]
[7] heatmap(::Array{Int64,2}, ::Array{Int64,2}, ::Array{Int64,2}) at C:\Users\aaron\.julia\packages\GR\8mv9N\src\GR.jl:3419
[8] top-level scope at REPL[2]:1
I’m pretty sure people are going to recommend using Plots.jl but I’m trying to select a plotting package to use in my package development, and Plots takes waaaaaaaaaaaaay too long to precompile and ttfp just does my head in.
No idea why the GR code wouldn’t work, but on the Plots issue: are you referring to Plots being too slow while you develop your package (i.e. in an iterative workflow where you just use Plots to visualise things every now and then) or Plots being too slow to precompile to integrate into your package as a dependency?
If it’s the former, are you using Revise for development? That should largely obviate the need to re-start your Julia session, so you only pay compilation cost once. If for some reasons you still have to re-start frequently you might want to consider having Plots in a custom sysimage using PackageCompiler.jl
If the latter, have you looked at Recipes? They’re made so you don’t have to depend on Plots in your package, but just on RecipesBase, and users will then using Plots separately if they want to plot.
Finally just so I give at least some info related to your actual question, have you tried GRUtils.jl? I don’t really know anything about it, but it seems that the GR developers recommend using this if one wants to work with GR directly (without the Plots wrapper).
Yes, I use Revise. My current development involves redefining a lot of structs, which requires restarting Julia.
I’m not sure what that means, but I’ll look into that, thanks!
For the output data I’m working on, there are a lot of features involved to look at, so I’ve produced a support niche plotting function that I can just pass the output data/struct instantiations to which will do all the steps of plotting for me. Super nice and convenient – in theory, if I can get along well with the plotting package.
Yep! I’m actually using it, but it’s just a little finicky and has a few bugs (which is not a surprise, it’s still in development), so I decided to check out other options, but I may stick with GRUtils for now since GR can’t even (supposedly) plot a heatmap.
I love the API of Plots.jl, but bloody heck it takes so long to load.
Again slightly off-topic, but for your development workflow consider:
Renaming rather than redefining structs - so work with MyStruct_1, when that doesn’t pan out to a find/replace MyStruct_1 => MyStruct_2 etc to avoid having to restart
Working with NamedTuples rather than structs
Also I think it should be possible to have quite complex plots with different features using RecipeBase
Couldn’t that be a strategy for Revise to deal with the struct changes? It could add a marker like _2 while loading the code, and perhaps warn the user of that, so that possible error messages are clear.
Cool, but I’m wondering if I can use GR.jl directly. Plots.jl takes too long to load, and if I can access all the functionality I want with just one of the backends, then I’ll do just that.
Why it doesn’t work is beyond me. I don’t understand the difference in functionality between the two in terms of, why wouldn’t the second one work? Is it still in development?
However, the example given does not take in x and y as the first two inputs. It only takes in z.
Passing x, y, andz doesn’t work.
The doc mentions something about changing the limits of the heatmap plot, so I might check that out instead.
I might read as much of the doc as is relevant, and if I don’t find an explanation for why heatmap(x, y, z) doesn’t work, then I’ll open an issue on GitHub.