juliaplots / statsplots.jl Goto Github PK
View Code? Open in Web Editor NEWStatistical plotting recipes for Plots.jl
License: Other
Statistical plotting recipes for Plots.jl
License: Other
It would be nice to have an option of adding a mean/median line to the violin plots. These lines should be "halved" if side
is not equal to :both
.
Request diagnostic plots for multiple regression. Some thing like this will be helpful
https://www.andrew.cmu.edu/user/achoulde/94842/homework/regression_diagnostics.html
I'd like to set the color individually for each series in a grouped bar plot, e.g.
using Plots, StatPlots
Plots.gr()
data = rand(6, 3)
p1 = groupedbar(data, color = [:red, :green, :blue])
But this produces the following plot:
I've also tried substituting color
for fillcolor
, seriescolor
, linecolor
, and markercolor
. It's only when I edit the series individually that I get the desired plot:
p2 = groupedbar(data)
p2.series_list[1].d[:fillcolor] = parse(Colorant, :red)
p2.series_list[2].d[:fillcolor] = parse(Colorant, :green)
p2.series_list[3].d[:fillcolor] = parse(Colorant, :blue)
Is there a way to do this that I'm not aware of? I've looked through the StatPlots readme and the groupedbar
code, and I haven't been able to figure it out. Thanks!
(Also, I'm not positive if this is a StatPlots issue, so if it isn't, I'll gladly open an issue in the appropriate package.)
I would like to see support for more powerful bar plots, including
Here are some images (from today's Nature magazine) representing common graphics designs with bar plots
Composite bar plots in subplots with simple error bars:
using RDatasets
using StatPlots
iris = dataset("datasets","iris")
density(iris, [:SepalLength, :PetalLength])
throws the following error:
LoadError: UndefVarError: isvertical not defined
while loading In[2], in expression starting on line 6
[inlined code] from /home/dzea/.julia/v0.4/StatPlots/src/hist.jl:7
in apply_recipe at /home/dzea/.julia/v0.4/RecipesBase/src/RecipesBase.jl:238
in _process_seriesrecipe at /home/dzea/.julia/v0.4/Plots/src/pipeline.jl:386
in _plot! at /home/dzea/.julia/v0.4/Plots/src/plot.jl:204
in plot at /home/dzea/.julia/v0.4/Plots/src/plot.jl:52
in density at /home/dzea/.julia/v0.4/Plots/src/Plots.jl:151
For some reason, StatPlots has suddenly stopped working for me:
julia> using StatPlots
INFO: Precompiling module StatPlots.
ERROR: LoadError: LoadError: UndefVarError: Plot not defined
in include_from_node1(::String) at ./loading.jl:488
in include_from_node1(::String) at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?
in include_from_node1(::String) at ./loading.jl:488
in include_from_node1(::String) at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?
in macro expansion; at ./none:2 [inlined]
in anonymous at ./<missing>:?
in eval(::Module, ::Any) at ./boot.jl:234
in eval(::Module, ::Any) at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?
in process_options(::Base.JLOptions) at ./client.jl:239
in _start() at ./client.jl:318
in _start() at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?
while loading /Users/tcovert/.julia/v0.5/StatPlots/src/marginalhist.jl, in expression starting on line 231
while loading /Users/tcovert/.julia/v0.5/StatPlots/src/StatPlots.jl, in expression starting on line 25
ERROR: Failed to precompile StatPlots to /Users/tcovert/.julia/lib/v0.5/StatPlots.ji.
in compilecache(::String) at ./loading.jl:593
in require(::Symbol) at ./loading.jl:422
in require(::Symbol) at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?
if it helps, here is my versioninfo()
and Pkg.status()
:
julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753* (2016-09-19 18:14 UTC)
Platform Info:
System: Darwin (x86_64-apple-darwin15.6.0)
CPU: Intel(R) Core(TM) i7-4578U CPU @ 3.00GHz
WORD_SIZE: 64
BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
julia> Pkg.status()
10 required packages:
- Blink 0.4.4
- DataFrames 0.8.5
- DataFramesMeta 0.1.3
- JLD 0.6.6
- Optim 0.6.1
- PDMats 0.5.1
- PlotlyJS 0.5.1
- Plots 0.10.0
- Rsvg 0.0.2
- StatPlots 0.1.1
56 additional packages:
- AxisAlgorithms 0.1.5
- BaseTestNext 0.2.2
- BinDeps 0.4.5
- Blosc 0.1.7
- Cairo 0.2.35
- Calculus 0.1.15
- Codecs 0.2.0
- ColorTypes 0.2.12
- Colors 0.6.9
- Compat 0.9.4
- DataArrays 0.3.10
- Distributions 0.11.0
- DocStringExtensions 0.2.1
- FileIO 0.2.0
- FixedPointNumbers 0.2.1
- FixedSizeArrays 0.2.5
- ForwardDiff 0.2.5
- GZip 0.2.20
- Graphics 0.1.3
- Gtk 0.10.4
- HDF5 0.7.0
- Hiccup 0.0.3
- Homebrew 0.4.0
- HttpCommon 0.2.6
- HttpParser 0.2.0
- HttpServer 0.1.7
- Interpolations 0.3.6
- Iterators 0.2.0
- JSON 0.8.0
- Juno 0.2.5
- KernelDensity 0.3.0
- LaTeXStrings 0.2.0
- Lazy 0.11.4
- LegacyStrings 0.1.1
- MacroTools 0.3.2
- MbedTLS 0.3.0
- Measures 0.0.3
- Media 0.2.4
- Mustache 0.1.2
- Mux 0.2.2
- NaNMath 0.2.2
- PlotThemes 0.1.0
- PlotUtils 0.2.0
- PositiveFactorizations 0.0.2
- Ratios 0.0.4
- RecipesBase 0.1.0
- Reexport 0.0.3
- Rmath 0.1.4
- SHA 0.3.0
- Showoff 0.0.7
- SortingAlgorithms 0.1.0
- StatsBase 0.11.1
- StatsFuns 0.3.1
- URIParser 0.1.6
- WebSockets 0.2.1
- WoodburyMatrices 0.2.0
marginalhist(iris, :PetalLength, :PetalWidth)
Not sure when this happened, but doesn't depend on DataFrames recipe, you would have the same issue with:
marginalhist(randn(1000), randn(1000), xlabel = :x , ylabel = :y)
The only way to get only the labels on the heatmap is:
marginalhist(randn(1000), randn(1000), xlabel = :x , ylabel = ["" :y])
Hi, thank you for making such a brilliant package in Julia.
I encountered a problem in which I cannot see a plot title because it seems to be out of window. Here is an example:
I made this plot with corrplot(θ[:,1001:2000]', title="NUTS", markersize=1)
using the GR backend but the title ("NUTS") is not displayed and small fraction of the plot is also out of display.
This is a complete reproducing script: https://gist.github.com/bicycle1885/77d7ad79fbd3fa195ff432be167812d6
Does the package support TimeSeries? The code below produces an error.
using TimeSeries
using StatPlots
dates = collect(Date(1999,1,1):Date(2000,12,31))
series = TimeArray(dates, rand(length(dates)))
plot(series)
The Recipe for Distributions does not work with distributions with Integer
domains.
Like Distributions.Bernoulli
, Distributions.BetaBinomial
, etc..
It would be great to be able to take subsets from a DataFrame to plot different lines or bar groups. So for example, if I have:
df = DataFrame(a=[1,2,3,4], b=["foo","bar","foo","bar"])
I'd like to generate a plot like so:
using StatPlots
groupedbar(df, :a, group=:b)
and get:
(this was generated by doing groupedbar([[1,3] [2,4]], lab=["foo", "bar"])
)
julia> using StatPlots
julia> violin(randn(10,3)) # Works fine
julia> violin(randn(10,10)) # Works fine
julia> violin(randn(10,11))
ERROR: BoundsError: attempt to access 10-element UnitRange{Int64} at index [11]
Stacktrace:
[1] throw_boundserror(::UnitRange{Int64}, ::Int64) at ./abstractarray.jl:434
[2] getindex(::UnitRange{Int64}, ::Int64) at ./range.jl:477
[3] macro expansion at /local/home/fredrikb/.julia/v0.6/StatPlots/src/violin.jl:21 [inlined]
[4] apply_recipe(::Dict{Symbol,Any}, ::Type{Val{:violin}}, ::UnitRange{Int64}, ::Array{Float64,1}, ::Void) at /local/home/fredrikb/.julia/v0.6/RecipesBase/src/RecipesBase.jl:287
[5] _process_seriesrecipe(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}) at /local/home/fredrikb/.julia/v0.6/Plots/src/pipeline.jl:406
[6] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Array{Float64,2}}) at /local/home/fredrikb/.julia/v0.6/Plots/src/plot.jl:233
[7] (::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::Array{Float64,2}) at ./<missing>:0
[8] #violin#672(::Array{Any,1}, ::Function, ::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at /local/home/fredrikb/.julia/v0.6/RecipesBase/src/RecipesBase.jl:381
[9] violin(::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at /local/home/fredrikb/.julia/v0.6/RecipesBase/src/RecipesBase.jl:381
Hi!
Is there a way to create grouped violin plots on a categorical x-axis, where the violins of different groups on one category do not overlap?
Similar behavior has been discussed in #56 for boxplots, but i didn't find a solution for that.
df = DataFrame(accuracy=Float64[],Cat1=String[],Cat2=String[])
for i = 1 : 100 push!(df,[rand() rand(["A"; "B"]) rand(["1" "2" "3"])]) end
violin(df,:Cat1,:accuracy,group=:Cat2,ylims=(0,1))
I cannot plot multiple series from a DataFrame with StatPlots. I can do it with the old Plots on my julia-0.4.6 install.
so:
using StatPlots
df = DataFrame(a = 1:100, b = randn(100), c = randn(100))
plot(df, :a, :b)
works, but
plot(df, :a, [:b :c])
doesn't, but it should, since
a = 1:100 ; b = randn(100); c = randn(100)
plot(a, [b, c])
works.
Issues with the current syntax for plotting from a DataFrame:
using StatPlots, DataFrames, RDatasets
iris = RDatasets.dataset("datasets","iris")
iris[:LongSepal] = iris[:SepalLength] .> median(iris[:SepalLength])
scatter(iris, :PetalLength, :PetalWidth, group = collect(zip(:Species,:LongSepal)))
but it'd work with the columns:
scatter(iris[:PetalLength], iris[:PetalWidth], group = collect(zip(iris[:Species],iris[:LongSepal])))
corrplot(iris, [:SepalLength :SepalWidth :PetalLength :PetalWidth])
it has to resort to heuristics to decide whether a symbol is a symbol or a column. For example
scatter(iris, :PetalLength, :PetalWidth, color = :blue)
plots in blue, unless there is a column in iris
called :blue
it has to resort to a runtime eval
call
My personal preference would be for syntactically replacing symbols with columns.
Possible options:
Adding a dispatch to plot
if the first argument is a DataFrame: in that case all symbols and expression are replaced by the respective columns, using the same functions we use now. It wouldn't resolve the ambiguity symbol/column + calling eval
but at least wouldn't mess with the recipe system
Officialize the @with
method from DataFramesMeta (a bit verbose but solves all of the above problems: group
and corrplot
work just fine and one can escape symbols to prevent them from becoming columns). Extra advantage: it can be used in blocks:
@with iris begin
plt = plot(:SepalLength,:PetalWidth)
plot!(:SepalLength,:PetalLength)
display(plt)
end
A slight modification of @with
where each symbol s
is not replaced by df[s]
, but by
haskey(df, s) ? df[s] : s
so that the user wouldn't need to escape symbols so often
Try and find a less verbose macro, though the implementation is not super straightforward. One bold possibility would be sth like:
macro plot(args...)
:(@with $(args[1]) $(Expr(:call, :plot, Base.tail(args)...)))
end
@plot(iris, :PetalLength, :PetalWidth)
But it seems hard to get it to work with keyword arguments/ different seriestypes.
Is there a way to provide legend labels there separately?
I've tried what I thought was a natural thing (supplying labels=["label1", "label2"]
), but that doesn't work.
Going through docs for recepies and even looking at SliceIt
recepie that seems to be called here didn't help, but I'll appreciate pointers.
using Plots
using StatPlots
density(randn(200),color=:red)
cdensity!(randn(200),color=:red)
The path for density
is black, the path for cdensity
is red. I'm having everything on master. Tested with:
I looked into the recipe code but I can't see any difference between density
and cdensity
that could cause this behavior. Setting the linestyle
works.
It is great having support for Distributions.jl.
Unfortunately there are some bugs. For example this works fine.
plot(Gamma(1, 1), fill=(0, 0.5, :skyblue), legend=false)
But this...
plot(Gamma(0.1, 1), fill=(0, 0.5, :skyblue), legend=false)
...works fine with plotlyjs() backend but shows an empty plot with gr() backend and something weird with pyplot() backend.
This gives an error.
plot(InverseGamma(2, 1), fill=(0, 0.5, :skyblue), legend=false)
ArgumentError: start and stop must be finite, got 0.0 and Inf
In sum, seems that Distributions support could use some attention.
Keep up the great work!
Which kind of defeats the purpose
I'd like to use groupedbar
in a plot recipe of my own. However, when I set seriestype := :groupedbar
, I get the following error:
ERROR: The backend must not support the series type Val{:groupedbar}, and there isn't a series recipe defined.
Stacktrace:
[1] apply_recipe(::Dict{Symbol,Any}, ::Type{Val{:groupedbar}}, ::UnitRange{Int64}, ::Array{Float64,1}, ::Void) at /home/rcepxl10/.julia/v0.6/RecipesBase/src/RecipesBase.jl:287
[2] _process_seriesrecipe(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}) at /home/rcepxl10/.julia/v0.6/Plots/src/pipeline.jl:406
[3] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Shockdec}) at /home/rcepxl10/.julia/v0.6/Plots/src/plot.jl:231
[4] #shockdec#155(::Array{Any,1}, ::Function) at /home/rcepxl10/.julia/v0.6/RecipesBase/src/RecipesBase.jl:363
[5] shockdec() at /home/rcepxl10/.julia/v0.6/RecipesBase/src/RecipesBase.jl:363
As far as I can tell, the difference between groupedbar
and other recipes defined in this package that can be successfully set as seriestype
s (e.g. marginalhist
, violin
) is that it's defined using @userplot
with the following function header (on master):
@recipe function f(g::GroupedBar)
Compare to marginalhist
's header, which uses @shorthands
and takes as its first argument a Type{Val{:marginalhist}}
:
@recipe function f(::Type{Val{:marginalhist}}, plt::AbstractPlot; density = false)
I spent a little time trying to modify groupedbar
to take in a Type{Val{:groupedbar}}
without much success, probably because I'm still trying to grasp how recipes work on the inside. Is this functionality (setting seriestype := :groupedbar
in a recipe) currently possible? If not, can I put in a request for it to be added? Am I understanding the reason groupedbar
currently can't be used as a seriestype
correctly?
using DataFrames, Plots, StatPlots
df = DataFrame(a = 1:100, b = randn(100), c = abs(randn(100)));
julia> plot(df, :a, [:b :c])
ERROR: MethodError: Cannot `convert` an object of type Array{Float64,1} to an object of type Float64
This may have arisen from a call to the constructor Float64(...),
since type constructors fall back to convert methods.
in discrete_value!(::Plots.Axis, ::Array{Any,1}) at /Users/tcovert/.julia/v0.5/Plots/src/axes.jl:428
in expand_extrema!(::Plots.Subplot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}) at /Users/tcovert/.julia/v0.5/Plots/src/axes.jl:294
in _expand_subplot_extrema(::Plots.Subplot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Symbol) at /Users/tcovert/.julia/v0.5/Plots/src/pipeline.jl:361
in _process_seriesrecipe(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}) at /Users/tcovert/.julia/v0.5/Plots/src/pipeline.jl:392
in _plot!(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{DataFrames.DataFrame,Symbol,Array{Symbol,2}}) at /Users/tcovert/.julia/v0.5/Plots/src/plot.jl:229
in #plot#258(::Array{Any,1}, ::Function, ::DataFrames.DataFrame, ::Vararg{Any,N}) at /Users/tcovert/.julia/v0.5/Plots/src/plot.jl:52
in plot(::DataFrames.DataFrame, ::Symbol, ::Vararg{Any,N}) at /Users/tcovert/.julia/v0.5/Plots/src/plot.jl:46
here is my Pkg.status():
julia> Pkg.status()
18 required packages:
- Blink 0.4.4
- DataFrames 0.7.8
- DataFramesMeta 0.1.3
- FixedEffectModels 0.3.0
- Formatting 0.2.0
- GLM 0.6.1
- JLD 0.6.6
- LaTeX 0.1.1
- MixedModels 0.5.6
- Optim 0.6.1
- PDMats 0.5.1
- PGFPlots 1.4.2
- PlotlyJS 0.5.1
- Plots 0.10.1
- PyPlot 2.2.4
- Rsvg 0.0.2
- Showoff 0.0.7
- StatPlots 0.2.0
69 additional packages:
- AxisAlgorithms 0.1.5
- BaseTestNext 0.2.2
- BinDeps 0.4.5
- Blosc 0.1.7
- Cairo 0.2.35
- Calculus 0.1.15
- Codecs 0.2.0
- ColorBrewer 0.3.0
- ColorTypes 0.2.12
- ColorVectorSpace 0.1.11
- Colors 0.6.9
- Compat 0.9.5
- Conda 0.4.0
- Contour 0.2.0
- DataArrays 0.3.10
- Discretizers 0.3.1
- Distributions 0.11.0
- DocStringExtensions 0.3.0
- FileIO 0.2.0
- FixedPointNumbers 0.2.1
- FixedSizeArrays 0.2.5
- ForwardDiff 0.2.5
- GZip 0.2.20
- Graphics 0.1.3
- Gtk 0.10.4
- HDF5 0.7.0
- Hiccup 0.0.3
- Homebrew 0.4.1
- HttpCommon 0.2.6
- HttpParser 0.2.0
- HttpServer 0.1.7
- ImageMagick 0.1.8
- Images 0.5.14
- Interpolations 0.3.6
- Iterators 0.2.0
- JSON 0.8.0
- Juno 0.2.5
- KernelDensity 0.3.0
- LaTeXStrings 0.2.0
- Lazy 0.11.4
- LegacyStrings 0.1.1
- MacroTools 0.3.2
- MathProgBase 0.5.7
- MbedTLS 0.3.0
- Measures 0.0.3
- Media 0.2.4
- Mustache 0.1.2
- Mux 0.2.2
- NLopt 0.3.3
- NaNMath 0.2.2
- PlotThemes 0.1.0
- PlotUtils 0.2.0
- PositiveFactorizations 0.0.3
- PyCall 1.7.2
- Ratios 0.0.4
- RecipesBase 0.1.0
- Reexport 0.0.3
- Rmath 0.1.4
- SHA 0.3.0
- SIUnits 0.1.0
- SortingAlgorithms 0.1.0
- StatsBase 0.11.1
- StatsFuns 0.3.1
- TexExtensions 0.0.3
- TikzPictures 0.3.5
- URIParser 0.1.6
- WebSockets 0.2.1
- WoodburyMatrices 0.2.0
- Zlib 0.1.12
It's not clear if group at supports plotting the bar side ways. That is the same as barh
.
using Plots
using StatPlots
using DataFrames
N = 100
data = DataFrame(a = rand(1:20, N), b = rand(1:20, N), c = rand(1:3, N))
scatter(data, :a, :b, group=:c)
gives
ERROR: LoadError: TypeError: typeassert: expected AbstractArray{Bool,N}, got Array{Nullable{Bool},1}
in copy!(::Array{Array{Int64,1},1}, ::Base.Generator{Array{Nullable{Int64},1},Plots.##129#131{Array{Nullable{Int64},1}}}) at ./abstractarray.jl:477
in _collect(::Type{Array{Int64,1}}, ::Base.Generator{Array{Nullable{Int64},1},Plots.##129#131{Array{Nullable{Int64},1}}}, ::Base.HasShape) at ./array.jl:251
in extractGroupArgs(::Array{Nullable{Int64},1}) at /home/tamas/.julia/v0.5/Plots/src/args.jl:765
in extractGroupArgs(::Symbol, ::DataFrames.DataFrame, ::Symbol, ::Vararg{Symbol,N}) at /home/tamas/.julia/v0.5/StatPlots/src/dataframes.jl:21
in _preprocess_args(::Dict{Symbol,Any}, ::Tuple{DataFrames.DataFrame,Symbol,Symbol}, ::Array{RecipesBase.RecipeData,1}) at /home/tamas/.julia/v0.5/Plots/src/pipeline.jl:29
in _process_userrecipes(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{DataFrames.DataFrame,Symbol,Symbol}) at /home/tamas/.julia/v0.5/Plots/src/pipeline.jl:60
in _plot!(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{DataFrames.DataFrame,Symbol,Symbol}) at /home/tamas/.julia/v0.5/Plots/src/plot.jl:171
in #plot#261(::Array{Any,1}, ::Function, ::DataFrames.DataFrame, ::Vararg{Any,N}) at /home/tamas/.julia/v0.5/Plots/src/plot.jl:52
in (::Plots.#kw##plot)(::Array{Any,1}, ::Plots.#plot, ::DataFrames.DataFrame, ::Symbol, ::Vararg{Symbol,N}) at ./<missing>:0
in #scatter#354(::Array{Any,1}, ::Function, ::DataFrames.DataFrame, ::Vararg{Any,N}) at /home/tamas/.julia/v0.5/Plots/src/Plots.jl:139
in (::Plots.#kw##scatter)(::Array{Any,1}, ::Plots.#scatter, ::DataFrames.DataFrame, ::Vararg{Any,N}) at ./<missing>:0
in include_from_node1(::String) at ./loading.jl:488
while loading /tmp/foo.jl, in expression starting on line 6
My Pkg.status()
is
53 required packages:
- Atom 0.5.8
- BenchmarkTools 0.0.6
- CSV 0.1.2+ master
- Cairo 0.2.35
- Colors 0.6.9
- DataFrames 0.8.3+ master
- DataFramesMeta 0.1.3
- Distributions 0.11.1
- Documenter 0.8.0+ master
- DualNumbers 0.2.3
- Fontconfig 0.1.1
- ForwardDiff 0.3.3+ master
- GLM 0.6.1
- GR 0.18.0
- GZip 0.2.20
- Gadfly 0.5.2
- Gallium 0.0.4
- IntervalSets 0.0.2+ master
- JuliaParser 0.7.4
- Klara 0.7.1+ master
- Lexicon 0.1.18
- Libz 0.2.2
- MacroTools 0.3.4
- Mamba 0.10.0
- Match 0.3.0
- MultivariateStats 0.3.1
- NLopt 0.3.3
- NamedArrays 0.5.3
- NamedTuples 1.0.0
- ObjFileBase 0.0.4
- OffsetArrays 0.2.12
- Optim 0.7.4+ master
- PGFPlots 1.4.3
- Parameters 0.6.0
- PkgDev 0.1.3
- Plotly 0.1.1
- Plots 0.10.3+ master
- Primes 0.1.2
- ProfileView 0.1.5
- ProgressMeter 0.3.3+ progress-count
- PyPlot 2.2.4
- QuantEcon 0.8.0
- Query 0.3.0
- RDatasets 0.2.0 master
- ReverseDiff 0.0.2
- Rsvg 0.0.2
- Showoff 0.0.7
- Sobol 0.2.0
- StatPlots 0.2.1+ master
- StatsBase 0.12.0
- StatsFuns 0.3.1+ master
- SuiteSparse 0.0.1
- UnicodePlots 0.2.2
126 additional packages:
- AMDB 0.0.0- master (unregistered, dirty)
- ASTInterpreter 0.0.4
- AbstractTrees 0.0.4
- ArgParse 0.4.0
- AutoAligns 0.0.0- master (unregistered, dirty)
- AutoHashEquals 0.0.10
- AxisAlgorithms 0.1.5
- BaseTestNext 0.2.2
- BinDeps 0.4.5
- Blink 0.5.0
- Blosc 0.1.7
- BufferedStreams 0.2.3
- COFF 0.0.2
- CRC 1.2.0
- Calculus 0.1.15
- CategoricalArrays 0.1.0
- CodeTools 0.4.3
- Codecs 0.2.0
- ColorBrewer 0.3.0
- ColorTypes 0.2.12
- ColorVectorSpace 0.1.12
- Combinatorics 0.3.2
- Compat 0.12.0
- Compose 0.4.4
- Conda 0.4.0
- ContinuousTransformations 0.0.0- master (unregistered)
- Contour 0.2.0
- DSP 0.1.1
- DWARF 0.1.0
- DataArrays 0.3.11
- DataStreams 0.1.2
- DataStructures 0.5.1
- Dates 0.4.4
- DebuggingUtilities 0.0.0- master (unregistered)
- DiffBase 0.0.2
- Discretizers 0.3.1
- Distances 0.3.2
- DocStringExtensions 0.3.1
- Docile 0.5.23
- ELF 0.1.0
- FileIO 0.2.1
- FixedPointNumbers 0.2.1
- FixedSizeArrays 0.2.5
- Formatting 0.2.0
- FunctionWrappers 0.0.1
- Glob 1.1.0
- Graphics 0.1.3
- Graphs 0.7.1
- Gtk 0.10.4
- GtkUtilities 0.1.0
- HDF5 0.7.2
- Hexagons 0.0.4
- Hiccup 0.1.1
- HiddenMarkovChains 0.0.0- master (unregistered)
- HttpCommon 0.2.6
- HttpParser 0.2.0
- HttpServer 0.1.7
- ImageMagick 0.1.8
- ImageView 0.2.0
- Images 0.5.14
- IndirectInference 0.0.0- master (unregistered, dirty)
- IniFile 0.2.5
- Interpolations 0.3.6
- Iterators 0.2.0
- JLD 0.6.8
- JSON 0.8.1
- Juno 0.2.5
- KernelDensity 0.3.0
- KeyTuples 0.0.0- master (unregistered, dirty)
- LMFlows 0.0.0- master (unregistered, dirty)
- LNR 0.0.2
- LaTeXStrings 0.2.0
- Lazy 0.11.5
- LegacyStrings 0.2.0
- LightGraphs 0.7.2
- LightXML 0.4.0
- LineSearches 0.1.4
- Loess 0.1.0
- MachO 0.0.4
- MathProgBase 0.5.10
- MbedTLS 0.4.2
- Measures 0.0.3
- Media 0.2.4
- Mustache 0.1.3
- Mux 0.2.2
- NaNMath 0.2.2
- NativeExpm 0.0.0- master (unregistered, dirty)
- NullableArrays 0.0.10
- PDMats 0.5.3
- ParserCombinator 1.7.11
- PlotThemes 0.1.0
- PlotUtils 0.3.0
- PlotlyJS 0.5.2
- Polynomials 0.1.2
- PositiveFactorizations 0.0.3
- PosteriorAnalysis 0.0.0- master (unregistered)
- PyCall 1.8.0
- RData 0.0.4
- Ratios 0.0.4
- Reactive 0.3.6
- RecipesBase 0.1.0
- Reel 0.2.1
- Reexport 0.0.3
- Requests 0.3.12
- Requires 0.3.0
- ReverseDiffSource 0.3.0
- Rmath 0.1.6
- SHA 0.3.0
- SIUnits 0.1.0
- SortingAlgorithms 0.1.0
- StructIO 0.0.2
- TerminalUI 0.0.2
- TexExtensions 0.0.3
- TextDataParsing 0.0.0- master (unregistered)
- TextTableRows 0.0.0- master (unregistered, dirty)
- TextWrap 0.1.6
- TikzPictures 0.3.5
- Tk 0.4.0
- URIParser 0.1.7
- VT100 0.0.2
- VideoIO 0.1.0
- WeakRefStrings 0.2.0
- WebSockets 0.2.1
- Winston 0.12.1
- WoodburyMatrices 0.2.1
- Zlib 0.1.12
I have tested this with the fix in JuliaPlots/Plots.jl#1436 as well, but it does not seem to fix it, unfortunately.
When I try to run the corrplot example from the documentation
M = randn(1000,4)
M[:,2] += 0.8sqrt(abs(M[:,1])) - 0.5M[:,3] + 5
M[:,3] -= 0.7M[:,1].^2 + 2
corrplot(M, label = ["x$i" for i=1:4])
I get the following error
LoadError: UndefVarError: default_gradient not defined
while loading In[1], in expression starting on line 8
[inlined code] from /home/admin/.julia/v0.4/StatPlots/src/corrplot.jl:24
in apply_recipe at /home/admin/.julia/v0.4/RecipesBase/src/RecipesBase.jl:238
in _process_userrecipes at /home/admin/.julia/v0.4/Plots/src/pipeline.jl:73
in _plot! at /home/admin/.julia/v0.4/Plots/src/plot.jl:157
in corrplot at /home/admin/.julia/v0.4/Plots/src/recipes.jl:37
in anonymous at no file
It seems that there is no function Plots.default_gradient
(I tried the 0.8 release, master, dev versions of Plots.jl).
The color of the diagonal histrograms in corrplot shouldn't simply be black. If the background is dark, black might not be a good color. The foreground color could be a good alternative, as this should contrast to the background color automatically.
#50 broke Plots exports. MWE:
using StatPlots
histogram(randn(1000))
#ERROR: UndefVarError: histogram not defined
The violin plot example doesn't work, as the const _box_halfwidth
has been removed from the boxplot file.
(also the alpha values are no longer as shown)
See: JuliaPlots/GraphRecipes.jl#1 (comment)
cc: @mauro3 (do you want to submit a PR?)
I managed to generate what I think are the beginnings of a recipe for plotting a tree with Hclust
types from Clustering.jl
:
using Distances
using Clustering
using StatPlots
include("hclustrecipe.jl")
m = rand(100,10)
dm = pairwise(Distances.Jaccard(), m)
clust = hclust(dm, :average)
plot(hclustplot(clust, true),seriestype=:path, color=:black,
yaxis=nothing, grid=false, legend=false, xticks=clust.labels)
Ultimately, I want to combine this with a heatmap to generate something that looks like this:
Wondering what the next steps are - in other words where should I submit a PR? Do I add it to Clustering.jl
, or somewhere in this repo?
Something strange is happening in Julia 0.6 with the import of Measures it seems :
using StatPlots
gr(size=(400,300))
using RDatasets
iris = dataset("datasets","iris")
@df iris corrplot([:SepalLength :SepalWidth :PetalLength :PetalWidth], grid = false)
ERROR: UndefVarError: mm not defined
Stacktrace:
[1] macro expansion at /localhome/romain/.julia/v0.6/StatPlots/src/corrplot.jl:21 [inlined]
[2] apply_recipe(::Dict{Symbol,Any}, ::StatPlots.CorrPlot) at /localhome/romain/.julia/v0.6/RecipesBase/src/RecipesBase.jl:287
[3] _process_userrecipes(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{StatPlots.CorrPlot}) at /localhome/romain/.julia/v0.6/Plots/src/pipeline.jl:81
[4] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{StatPlots.CorrPlot}) at /localhome/romain/.julia/v0.6/Plots/src/plot.jl:175
[5] (::RecipesBase.#kw##plot)(::Array{Any,1}, ::RecipesBase.#plot, ::StatPlots.CorrPlot) at ./<missing>:0
[6] #corrplot#23(::Array{Any,1}, ::Function, ::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at /localhome/romain/.julia/v0.6/RecipesBase/src/RecipesBase.jl:363
[7] (::StatPlots.#kw##corrplot)(::Array{Any,1}, ::StatPlots.#corrplot, ::Array{Float64,2}, ::Vararg{Array{Float64,2},N} where N) at ./<missing>:0
Caused by margin --> 1mm
in corrplot
(or any other recipe trying to use mm
). This happens both with the tagged version and the latest checkout version.
There are no x-tick labels along the bottom plots. However, they should be there, as they are enabled in this line (as far as I understand).
The latest (0.7.1) release caused a new issue with the @df
macro
julia> using Plots, StatPlots, DataFrames
julia> @df DataFrame(x=[1,2], y=[3,4]) begin
end
julia> @df DataFrame(x=[1,2], y=[3,4]) begin
plot(:x, :y)
end
ERROR: StackOverflowError:
This used to work, and was convenient for doing multiple plots.
I'm getting an integer division error for a violin plot.
# I tried plotlyjs() and pyplot() here
violin(rand(10))
results in
DivideError: integer division error
in cycle at /home/pawel/.julia/v0.5/Plots/src/utils.jl:240 [inlined]
in #10 at /home/pawel/.julia/v0.5/Plots/src/utils.jl:195 [inlined]
in Predicate at ./reduce.jl:183 [inlined]
in mapreduce_sc_impl(::Base.Predicate{Plots.##10#11{Int64}}, ::Base.#|, ::Tuple{Array{Float64,1},Array{Float64,1}}) at ./reduce.jl:198
in start(::Plots.SegmentsIterator) at /home/pawel/.julia/v0.5/Plots/src/utils.jl:201
in plotly_series_shapes(::Plots.Plot{Plots.PlotlyBackend}, ::Plots.Series) at /home/pawel/.julia/v0.5/Plots/src/backends/plotly.jl:545
in plotly_series(::Plots.Plot{Plots.PlotlyBackend}, ::Plots.Series) at /home/pawel/.julia/v0.5/Plots/src/backends/plotly.jl:383
in plotly_series_json(::Plots.Plot{Plots.PlotlyBackend}) at /home/pawel/.julia/v0.5/Plots/src/backends/plotly.jl:594
in html_body(::Plots.Plot{Plots.PlotlyBackend}, ::Void) at /home/pawel/.julia/v0.5/Plots/src/backends/plotly.jl:612
in _show at /home/pawel/.julia/v0.5/Plots/src/backends/plotly.jl:639 [inlined]
in show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("image/svg+xml")}, ::Plots.Plot{Plots.PlotlyBackend}) at /home/pawel/.julia/v0.5/Plots/src/output.jl:171
in show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("text/html")}, ::Plots.Plot{Plots.PlotlyBackend}) at /home/pawel/.julia/v0.5/Plots/src/output.jl:151
in show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::String, ::Plots.Plot{Plots.PlotlyBackend}) at ./multimedia.jl:33
in #sprint#304(::Void, ::Function, ::Int64, ::Function, ::String, ::Vararg{Any,N}) at ./strings/io.jl:37
in display_dict(::Plots.Plot{Plots.PlotlyBackend}) at /home/pawel/.julia/v0.5/Plots/src/output.jl:240
in execute_request(::ZMQ.Socket, ::IJulia.Msg) at /home/pawel/.julia/v0.5/IJulia/src/execute_request.jl:200
in eventloop(::ZMQ.Socket) at /home/pawel/.julia/v0.5/IJulia/src/eventloop.jl:8
in (::IJulia.##9#15)() at ./task.jl:360
Consider the following piece of code:
using StatPlots, DataFrames
df_any = DataFrame(Any, 0, 1)
df_array_any = DataFrame(Array{Any}(0, 1))
for i in 1:10
push!(df_any, rand())
push!(df_array_any, rand())
end
@df df_any plot(:x1) # Error: "Missing data of type Any is not supported"
@df df_array_any plot(:x1) # works
I'm not sure if this is related to StatPlots or DataFrames, if this is expected or an issue. I was just a little surprised.
cc: @piever
hi,
i tried and saw
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.0 (2017-06-19 13:05 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-apple-darwin13.4.0
julia> using DataFrames, StatPlots, Query
julia> df = DataFrame(a = 1:10, b = 10*rand(10), c = 10 * rand(10))
10×3 DataFrames.DataFrame
│ Row │ a │ b │ c │
├─────┼────┼─────────┼──────────┤
│ 1 │ 1 │ 8.12892 │ 3.54923 │
│ 2 │ 2 │ 4.32659 │ 2.44013 │
│ 3 │ 3 │ 2.38561 │ 1.25754 │
│ 4 │ 4 │ 6.44253 │ 3.3041 │
│ 5 │ 5 │ 9.10658 │ 2.33738 │
│ 6 │ 6 │ 5.89228 │ 6.60129 │
│ 7 │ 7 │ 1.41004 │ 6.80407 │
│ 8 │ 8 │ 6.71332 │ 6.91759 │
│ 9 │ 9 │ 8.29649 │ 7.71453 │
│ 10 │ 10 │ 8.18642 │ 0.549369 │
julia> df |>
@where(_.a > 5) |>
@select({_.b, d = _.c-10}) |>
@df scatter(:b, :d)
ERROR: MethodError: no method matching @df(::Expr)
Closest candidates are:
@df(::ANY, ::ANY) at /Users/74097/.julia/v0.6/StatPlots/src/df.jl:12
julia> Pkg.status.(["StatPlots","Query","DataFrames"])
- StatPlots 0.5.0
- Query 0.6.0 v0.7.2
- DataFrames 0.10.1
I am making a box plot grouped by a certain variable. By default the boxes appear overlapping on each other. Is there a way to have them side-by-side to avoid the overlap?
More bikeshedding! After fixing the syntax to plot DataFrames in #74, we need to update the groupapply
syntax to match it.
Example call (as it is now on master):
grp_error = groupapply(:density, school, :MAch, group = :Sx, compute_error = (:across, :School), axis_type = :continuous, summarize = (mean, sem), bandwidth = 0.5)
plot(grp_error, linewidth = 2)
What this does is to take the :MAch
column from the dataframe school
, splits by :Sx
, splits again by :School
, computes the kernel density with bandwidth = 0.5
, put back together all the schools using the functions provided in summarize
to compute mean and error and then plots the traces corresponding to each:Sx
.
Issues:
groupapply
call gets messy pretty quiclky and the result is a bit magicalA simple solution of problem 1 would be the obvious translation:
grp_error = @df school groupapply(:density, :MAch, group = :Sx, compute_error = (:across, :School), axis_type = :continuous, summarize = (mean, sem), bandwidth = 0.5)
but problem 2 remains.
A possible proposal is to draw inspiration from the DataFramesMeta syntax (as we did with @df
), in particular the @linq
macro to concatenate operator. What I'd propose is something along the lines of:
@groupapply school |>
where(:Minrty .== "Yes") |> # data selection (currently not possible, but I think it can be nice to have)
group(:Sx) |> # split (correspons do group = :Sx in a plot call)
compute_error(:across, :School) |> # How to split to compute error (:bootstrap or :none also possible)
summarize(mean, sem) |> #how to summarize the traces from previous step to get estimate and error
axis_type(:continuous) |> #define how to treat the x axis: (:binned :discrete or :continuous)
density(:MAch, bandwidth = 0.5) |> # analysis function (in this case kernel density)
plot(linewidth = 2) #plot command (if omitted the statistical object is returned instead)
Thoughts? In particular I'd like to understand if we're happy with a more pipeline
syntax, what considerations we have about the order of the functions and whether they should be together or separate.
Just found that the stack version of the groupbar example doesn't work for plotlyjs().
using Plots, StatPlots; plotlyjs() groupedbar(rand(10,3), bar_position = :stack, bar_width=0.7)
pyplot() and gr() backend works fine (below)
using Plots, StatPlots; pyplot() groupedbar(rand(10,3), bar_position = :stack, bar_width=0.7)
Hello, with the introduction of the @df
macro I have code that stopped working.
julia> mydata = DataFrame(a = 1:10, b = 10*rand(10), c = 10 * rand(10))
10×3 DataFrames.DataFrame
│ Row │ a │ b │ c │
├─────┼────┼──────────┼───────────┤
│ 1 │ 1 │ 2.63671 │ 0.170561 │
│ 2 │ 2 │ 0.242708 │ 2.91754 │
│ 3 │ 3 │ 7.30491 │ 7.04883 │
│ 4 │ 4 │ 5.72754 │ 9.73496 │
│ 5 │ 5 │ 5.47582 │ 9.08884 │
│ 6 │ 6 │ 9.27389 │ 0.528901 │
│ 7 │ 7 │ 2.01602 │ 9.47871 │
│ 8 │ 8 │ 7.81227 │ 5.78101 │
│ 9 │ 9 │ 2.22013 │ 5.59383 │
│ 10 │ 10 │ 8.19924 │ 0.0320381 │
julia> @df mydata plot(:a, [:b :c], colour = [:red :blue])
julia> @df mydata plot(:a, [:b :c], colour = [:red :blue],xtickfont=Plots.font(16))
ERROR: syntax: malformed expression
If I specify the font as before I get a malformed expression
syntax error.
Thanks
I'm trying to execute the example from the README.md
(after adding the missing using
statements):
using Plots
using Distributions
using StatPlots
plot(Normal(3,5), fill=(0, .5,:orange))
However, instead of a plot I am getting:
julia> plot(Normal(3,5), fill=(0, .5,:orange))
ERROR: In convertToAnyVector, could not handle the argument types: (Distributions.Normal{Float64},)
in macro expansion at /.julia/v0.5/Plots/src/series.jl:128 [inlined]
in apply_recipe(::Dict{Symbol,Any}, ::Type{Plots.SliceIt}, ::Distributions.Normal{Float64}, ::LinSpace{Float64}, ::Void) at /.julia/v0.5/RecipesBase/src/RecipesBase.jl:238
in _process_userrecipes(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{Distributions.Normal{Float64}}) at /.julia/v0.5/Plots/src/pipeline.jl:73
in _plot!(::Plots.Plot{Plots.PyPlotBackend}, ::Dict{Symbol,Any}, ::Tuple{Distributions.Normal{Float64}}) at /.julia/v0.5/Plots/src/plot.jl:171
in (::Plots.#kw##plot)(::Array{Any,1}, ::Plots.#plot, ::Distributions.Normal{Float64}) at ./<missing>:0
Is there a package (or another statement) that I'm missing?
using KernelDensity
using StatPlots; pyplot()
plot(kde(randn(1000,2)))
PyError (ccall(@pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, arg, kw)) <class 'TypeError'>
TypeError('Length of x must be number of columns in z.',)
File "/usr/lib/python3.6/site-packages/matplotlib/init.py", line 1898, in inner
return func(ax, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 5825, in contour
contours = mcontour.QuadContourSet(self, *args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/contour.py", line 864, in init
self._process_args(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/contour.py", line 1429, in _process_args
x, y, z = self._contour_args(args, kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/contour.py", line 1508, in _contour_args
x, y, z = self._check_xyz(args[:3], kwargs)
File "/usr/lib/python3.6/site-packages/matplotlib/contour.py", line 1555, in _check_xyz
raise TypeError("Length of x must be number of columns in z.")
This is probably just me not understanding something very simple about how Symbols are passed, but
using StatPlots, DataFrames
smallDf = DataFrame(A = rand(10),B=rand(10))
x = :A
@df smallDf histogram(x)
Throws
ERROR: ArgumentError: invalid index: Union{}[]
Stacktrace:
[1] #create_columns_from_iterabletable#1(::TableTraitsUtils.#_default_array_factory, ::Function, ::DataFrames.DataFrame, ::Array{Union{},1}) at /localhome/romain/.julia/v0.6/TableTraitsUtils/src/TableTraitsUtils.jl:142
[2] extract_columns_from_iterabletable(::DataFrames.DataFrame) at /localhome/romain/.julia/v0.6/StatPlots/src/df.jl:100
Whereas @df smallDf histogram(:A)
or smallDf[x]
work as I would expect.
This is with the latest master (also on the latest release) and julia 0.6.1.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.