From 982a512ebdd388627ff6bce1a9908ab11adc2c91 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Tue, 26 Apr 2016 16:01:50 -0400 Subject: [PATCH] pyplot support for pie charts --- src/Plots.jl | 4 ++-- src/backends/pyplot.jl | 11 ++++++++++- src/backends/supported.jl | 2 +- src/plot.jl | 2 +- src/series_args.jl | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Plots.jl b/src/Plots.jl index 9fe92f32..1367ca67 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -189,8 +189,8 @@ vline(args...; kw...) = plot(args...; kw..., linetype = :vline) vline!(args...; kw...) = plot!(args...; kw..., linetype = :vline) ohlc(args...; kw...) = plot(args...; kw..., linetype = :ohlc) ohlc!(args...; kw...) = plot!(args...; kw..., linetype = :ohlc) -pie(args...; kw...) = plot(args...; kw..., linetype = :pie) -pie!(args...; kw...) = plot!(args...; kw..., linetype = :pie) +pie(args...; kw...) = plot(args...; kw..., linetype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing) +pie!(args...; kw...) = plot!(args...; kw..., linetype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing) contour(args...; kw...) = plot(args...; kw..., linetype = :contour) contour!(args...; kw...) = plot!(args...; kw..., linetype = :contour) contour3d(args...; kw...) = plot(args...; kw..., linetype = :contour3d) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index ed213f81..29a118a6 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -581,6 +581,15 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) push!(handles, handle) end + if lt == :pie + handle = ax[:pie](y; + # label = d[:label], + # colors = # a vector of colors? + labels = x + ) + push!(handles, handle) + end + d[:serieshandle] = handles # smoothing @@ -944,7 +953,7 @@ function addPyPlotLegend(plt::Plot, ax) args = filter(x -> !(x[:linetype] in ( :hist,:density,:hexbin,:hist2d,:hline,:vline, :contour,:contour3d,:surface,:wireframe, - :heatmap,:path3d,:scatter3d + :heatmap,:path3d,:scatter3d, :pie )), plt.seriesargs) args = filter(x -> x[:label] != "", args) if length(args) > 0 diff --git a/src/backends/supported.jl b/src/backends/supported.jl index 0797ca27..373e4e0e 100644 --- a/src/backends/supported.jl +++ b/src/backends/supported.jl @@ -111,7 +111,7 @@ supportedTypes(::PyPlotBackend) = [ :none, :line, :path, :steppre, :steppost, :shape, :scatter, :hist2d, :hexbin, :hist, :density, :bar, :sticks, :box, :violin, :quiver, - :hline, :vline, :heatmap, + :hline, :vline, :heatmap, :pie, :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe ] supportedStyles(::PyPlotBackend) = [:auto, :solid, :dash, :dot, :dashdot] diff --git a/src/plot.jl b/src/plot.jl index e5edccd4..e10553f3 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -167,7 +167,7 @@ function _add_series(plt::Plot, d::KW, ::Void, args...; for (i,di) in enumerate(seriesArgList) plt.n += 1 - if !stringsSupported() + if !stringsSupported() && di[:linetype] != :pie setTicksFromStringVector(d, di, :x, :xticks) setTicksFromStringVector(d, di, :y, :yticks) setTicksFromStringVector(d, di, :z, :zticks) diff --git a/src/series_args.jl b/src/series_args.jl index 2dceba87..36156e79 100644 --- a/src/series_args.jl +++ b/src/series_args.jl @@ -7,7 +7,7 @@ typealias FuncOrFuncs @compat(Union{Function, AVec{Function}}) -all3D(d::KW) = trueOrAllTrue(lt -> lt in (:contour, :heatmap, :surface, :wireframe), get(d, :linetype, :none)) +all3D(d::KW) = trueOrAllTrue(lt -> lt in (:contour, :heatmap, :surface, :wireframe, :contour3d), get(d, :linetype, :none)) # missing convertToAnyVector(v::@compat(Void), d::KW) = Any[nothing], nothing