Hello, is there anyway i can plot a 3D bar graph with using StatPlots
?
Like this one:
In this case, i got a 17x25 matrix.
If thats not possible, wich package can do it?
Hello, is there anyway i can plot a 3D bar graph with using StatPlots
?
Like this one:
In this case, i got a 17x25 matrix.
If thats not possible, wich package can do it?
I just sketched out a recipe for this in Makie:
# installation
# Pkg.add("Makie")
# Pkg.checkout("AbstractPlotting")
# Pkg.checkout("Makie")
using Makie
data = rand(10, 10)
# TODO turn this into a 3d bar plot recipe
scene = meshscatter(
0..1, 0..1, fill(0, 10, 10),
# there is a problem with the limits for z position == fill(0, xdim, ydim)
# so we need to pass the limits seperately (meshscatter ignores the markersize, so it seems to Makie as if the plot is 2D)
limits = Rect3D(Vec3f0(-0.2, -0.2, 0.0), Vec3f0(1.4)),
marker = Rect3D(Vec3f0(-0.5, -0.5, 0), Vec3f0(1)),
markersize = Vec3f0.(0.05, 0.05, vec(data)),
# the default light yields a pretty bad lighting of the bars
light = Vec3f0[(1.0, 1.0, 1.0), (0.1, 0.1, 0.1), (0.9, 0.9, 0.9), (0.0, 5.0, 10.0)],
# either a single color
# color = :skyblue2
# or just pass the values you want to have colored to `color` and a colormap will be used
color = vec(data)
)
Hello, thanks for your reply. But i’m getting a lot of errors, wich i have no idea how to fix.
I did all the installation process, but when i run my code, i get these errors:
WARNING: Method definition set_theme!() in module AbstractPlotting at C:\Users\Muril\.julia\v0.6\Abs
tractPlotting\src\scenes.jl:229 overwritten at C:\Users\Muril\.julia\v0.6\AbstractPlotting\src\scene
s.jl:234.
WARNING: --output requested, but no modules defined during run
WARNING: The call to compilecache failed to create a usable precompiled cache file for module FFTW.
Got:
WARNING: Cache file "C:\Users\Muril\.julia\lib\v0.6\FFTW.ji" not found.
WARNING: eval from module Main to ImageCore:
Expr(:call, Expr(:., :Base, :include_from_node1)::Any, "C:\Users\Muril\.julia\v0.6\FFTW\src\FFTW.jl"
)::Any
** incremental compilation may be broken for this module **
WARNING: could not import AbstractPlotting.arguments into Makie
WARNING: could not import AbstractPlotting.onpick into Makie
WARNING: could not import AbstractPlotting.pick into Makie
ERROR: LoadError: could not open file C:\Users\Muril\.julia\v0.6\GLFW\src\../deps/deps.jl
Stacktrace:
[1] include_from_node1(::String) at .\loading.jl:576
[2] include(::String) at .\sysimg.jl:14
[3] include_from_node1(::String) at .\loading.jl:576
[4] include(::String) at .\sysimg.jl:14
[5] anonymous at .\<missing>:2
while loading C:\Users\Muril\.julia\v0.6\GLFW\src\GLFW.jl, in expression starting on line 6
ERROR: LoadError: LoadError: Failed to precompile GLFW to C:\Users\Muril\.julia\lib\v0.6\GLFW.ji.
Stacktrace:
[1] compilecache(::String) at .\loading.jl:710
[2] _require(::Symbol) at .\loading.jl:463
[3] require(::Symbol) at .\loading.jl:405
[4] include_from_node1(::String) at .\loading.jl:576
[5] include(::String) at .\sysimg.jl:14
[6] include_from_node1(::String) at .\loading.jl:576
[7] include(::String) at .\sysimg.jl:14
[8] anonymous at .\<missing>:2
while loading C:\Users\Muril\.julia\v0.6\Makie\src\glbackend/glbackend.jl, in expression starting on
line 1
while loading C:\Users\Muril\.julia\v0.6\Makie\src\Makie.jl, in expression starting on line 71
ERROR: LoadError: Failed to precompile Makie to C:\Users\Muril\.julia\lib\v0.6\Makie.ji.
Stacktrace:
[1] compilecache(::String) at .\loading.jl:710
[2] _require(::Symbol) at .\loading.jl:497
[3] require(::Symbol) at .\loading.jl:405
[4] include_string(::String, ::String) at .\loading.jl:522
[5] include_string(::Module, ::String, ::String) at C:\Users\Muril\.julia\v0.6\Compat\src\Compat.jl
[1] compilecache(::String) at .\loading.jl:710
[2] _require(::Symbol) at .\loading.jl:463
[3] require(::Symbol) at .\loading.jl:405
[4] include_from_node1(::String) at .\loading.jl:576
[5] include(::String) at .\sysimg.jl:14
[6] include_from_node1(::String) at .\loading.jl:576
[7] include(::String) at .\sysimg.jl:14
[8] anonymous at .\<missing>:2
while loading C:\Users\Muril\.julia\v0.6\Makie\src\glbackend/glbackend.jl, in expression starting on line 1
while loading C:\Users\Muril\.julia\v0.6\Makie\src\Makie.jl, in expression starting on line 71
ERROR: LoadError: Failed to precompile Makie to C:\Users\Muril\.julia\lib\v0.6\Makie.ji.
Stacktrace:
[1] compilecache(::String) at .\loading.jl:710
[2] _require(::Symbol) at .\loading.jl:497
[3] require(::Symbol) at .\loading.jl:405
[4] include_string(::String, ::String) at .\loading.jl:522
[5] include_string(::Module, ::String, ::String) at C:\Users\Muril\.julia\v0.6\Compat\src\Compat.jl:88
[6] (::Atom.##112#116{String,String})() at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:109
[7] withpath(::Atom.##112#116{String,String}, ::String) at C:\Users\Muril\.julia\v0.6\CodeTools\src\utils.jl:30
[8] withpath(::Function, ::String) at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:38
[9] hideprompt(::Atom.##111#115{String,String}) at C:\Users\Muril\.julia\v0.6\Atom\src\repl.jl:67
[10] macro expansion at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:106 [inlined]
[11] (::Atom.##110#114{Dict{String,Any}})() at .\task.jl:80
while loading C:\Users\Muril\AppData\Local\atom\app-1.28.0\Arquivos Feitos\dsadasdsa.jl, in expression starting on line 2
GLFW didn’t build!
Have a look at:
Although it seems like you’re on windows. Did you see any messages about downloading problems?
Ok, i did the Pkg.build("GLFW")
command, and my code is running with these warnings:
WARNING: using Makie.AbstractPlotting in module Main conflicts with an existing identifier.
WARNING: using Makie.Contour in module Main conflicts with an existing identifier.
But i can’t see the graphic anywhere.
I’m used to see my graphics at the Plots Tab (i’m using Atom). Should i put display()
somewhere in this recipe of yours?
And no, i didn’t saw any messages about download problems.
display(scene) or just eval scene in atom and a window should pop up… i disabled the plot pane for now, since it just annoys me a lot, and i was waiting for a nice way to turn the plot pane on and off in atom
Hello sdanisch,
Could you please help me scale my graphic using this recipe of yours?
Here’s my code:
using Makie
Nt = 17;
hmax = 25;
DHIv = [1 0 0 0 0.2159 0 0.0711 0 0 0 0.0508 0 0.0363 0 0 0 0.0366 0 0.0302 0 0 0 0.0072 0 0.0132
1 0 0 0 4.1856 0 1.3776 0 0 0 0.9857 0 0.7046 0 0 0 0.7106 0 0.5852 0 0 0 0.1392 0 0.2558
1 0 0 0 4.2702 0 1.3781 0 0 0 1.0913 0 0.7582 0 0 0 0.7024 0 0.5250 0 0 0 0.2040 0 0.3389
1 0 0 0 4.3953 0 1.3816 0 0 0 1.2441 0 0.8097 0 0 0 0.6067 0 0.4018 0 0 0 0.2920 0 0.4126
1 0 0 0 4.4176 0 1.3820 0 0 0 1.2683 0 0.8083 0 0 0 0.5635 0 0.3793 0 0 0 0.2990 0 0.4035
1 0 0 0 4.5260 0 1.4505 0 0 0 1.3405 0 0.6766 0 0 0 0.2434 0 0.6763 0 0 0 0.2305 0 0.1229
1 0 0 0 4.5373 0 1.4579 0 0 0 1.3584 0 0.6898 0 0 0 0.2522 0 0.7090 0 0 0 0.2496 0 0.1362
1 0 0 0 4.5985 0 1.4977 0 0 0 1.4552 0 0.7606 0 0 0 0.3001 0 0.8856 0 0 0 0.3527 0 0.2081
1 0 0 0 4.5984 0 1.4976 0 0 0 1.4550 0 0.7604 0 0 0 0.3000 0 0.8852 0 0 0 0.3524 0 0.2079
1 0 0 0 4.2701 0 1.3781 0 0 0 1.0913 0 0.7582 0 0 0 0.7024 0 0.5250 0 0 0 0.2040 0 0.3389
1 0 0 0 5.0225 0 2.0788 0 0 0 0.5666 0 0.5525 0 0 0 1.0558 0 1.4817 0 0 0 0.3798 0 0.3032
1 0 0 0 5.4317 0 2.5101 0 0 0 0.3696 0 0.3863 0 0 0 0.9775 0 1.5363 0 0 0 0.4719 0 0.4416
1 0 0 0 5.4316 0 2.5099 0 0 0 0.3695 0 0.3862 0 0 0 0.9771 0 1.5356 0 0 0 0.4716 0 0.4413
1 0 0 0 6.4206 0 3.6934 0 0 0 1.0623 0 0.4425 0 0 0 0.2155 0 0.1719 0 0 0 0.0357 0 0.0195
1 0 0 0 6.6974 0 4.0261 0 0 0 1.3388 0 0.6224 0 0 0 0.4267 0 0.4496 0 0 0 0.3270 0 0.1880
1 0 0 0 6.8614 0 4.2373 0 0 0 1.5617 0 0.7987 0 0 0 0.8440 0 1.1716 0 0 0 0.0770 0 0.0272
1 0 0 0 6.8614 0 4.2373 0 0 0 1.5617 0 0.7987 0 0 0 0.8440 0 1.1716 0 0 0 0.0770 0 0.0272]
# turn this into a 3d bar plot recipe
scene = meshscatter(
0..2, 0..2, fill(0, hmax, Nt),
# there is a problem with the limits for z position == fill(0, xdim, ydim)
# so we need to pass the limits seperately (meshscatter ignores the markersize, so it seems to Makie as if the plot is 2D)
#limits = Rect3D(Vec3f0(-0.2, -0.2, 0.0), Vec3f0(1.4)),
#marker = Rect3D(Vec3f0(-0.5, -0.5, 0), Vec3f0(1)),
#markersize = Vec3f0.(0.05, 0.05, vec(DHIv)),
limits = Rect3D(Vec3f0(0,0,0), Vec3f0(hmax,Nt,7)),
marker = Rect3D(Vec3f0(-0.2, -0.2, 0), Vec3f0(1)),
markersize = Vec3f0.(0.05, 0.05, vec(DHIv)),
# the default light yields a pretty bad lighting of the bars
light = Vec3f0[(1.0, 1.0, 1.0), (0.1, 0.1, 0.1), (0.9, 0.9, 0.9), (0.0, 5.0, 10.0)],
# either a single color
# color = :skyblue2
# or just pass the values you want to have colored to `color` and a colormap will be used
color = vec(DHIv)
)
display(scene)
I’ve been trying to scale it, changing those parameters, but couldn’t do it. I really don’t understand how those functions (meshscatter
, fill
, etc) works.
I’ve been trying to make it appear something like the graphic i posted at the start of the topic. So i provided you the 17x25 data matrix, DHIv
, of that graphic.
And one last question, how can i change the labels of the x,y and z-axis? And put a title in the graphic?
Hi sdanisch
I fail to build ImageMagick
but I try to install it, it can work