added density type
This commit is contained in:
parent
52ba7cdbff
commit
ef7370f56d
@ -35,6 +35,8 @@ export
|
|||||||
bar!,
|
bar!,
|
||||||
histogram,
|
histogram,
|
||||||
histogram!,
|
histogram!,
|
||||||
|
density,
|
||||||
|
density!,
|
||||||
heatmap,
|
heatmap,
|
||||||
heatmap!,
|
heatmap!,
|
||||||
hexbin,
|
hexbin,
|
||||||
@ -135,10 +137,12 @@ bar(args...; kw...) = plot(args...; kw..., linetype = :bar)
|
|||||||
bar!(args...; kw...) = plot!(args...; kw..., linetype = :bar)
|
bar!(args...; kw...) = plot!(args...; kw..., linetype = :bar)
|
||||||
histogram(args...; kw...) = plot(args...; kw..., linetype = :hist)
|
histogram(args...; kw...) = plot(args...; kw..., linetype = :hist)
|
||||||
histogram!(args...; kw...) = plot!(args...; kw..., linetype = :hist)
|
histogram!(args...; kw...) = plot!(args...; kw..., linetype = :hist)
|
||||||
|
density(args...; kw...) = plot(args...; kw..., linetype = :density)
|
||||||
|
density!(args...; kw...) = plot!(args...; kw..., linetype = :density)
|
||||||
heatmap(args...; kw...) = plot(args...; kw..., linetype = :heatmap)
|
heatmap(args...; kw...) = plot(args...; kw..., linetype = :heatmap)
|
||||||
heatmap!(args...; kw...) = plot!(args...; kw..., linetype = :heatmap)
|
heatmap!(args...; kw...) = plot!(args...; kw..., linetype = :heatmap)
|
||||||
hexbin(args...; kw...) = plot(args...; kw..., linetype = :hexbin)
|
hexbin(args...; kw...) = plot(args...; kw..., linetype = :hexbin)
|
||||||
hexbin!(args...; kw...) = plot!(args...; kw..., linetype = :hexbin)
|
hexbin!(args...; kw...) = plot!(args...; kw..., linetype = :hexbin)
|
||||||
sticks(args...; kw...) = plot(args...; kw..., linetype = :sticks, marker = :ellipse)
|
sticks(args...; kw...) = plot(args...; kw..., linetype = :sticks, marker = :ellipse)
|
||||||
sticks!(args...; kw...) = plot!(args...; kw..., linetype = :sticks, marker = :ellipse)
|
sticks!(args...; kw...) = plot!(args...; kw..., linetype = :sticks, marker = :ellipse)
|
||||||
hline(args...; kw...) = plot(args...; kw..., linetype = :hline)
|
hline(args...; kw...) = plot(args...; kw..., linetype = :hline)
|
||||||
|
|||||||
19
src/args.jl
19
src/args.jl
@ -10,7 +10,7 @@ const _allAxes = [:auto, :left, :right]
|
|||||||
const _3dTypes = [:path3d, :scatter3d]
|
const _3dTypes = [:path3d, :scatter3d]
|
||||||
const _allTypes = vcat([
|
const _allTypes = vcat([
|
||||||
:none, :line, :path, :steppre, :steppost, :sticks, :scatter,
|
:none, :line, :path, :steppre, :steppost, :sticks, :scatter,
|
||||||
:heatmap, :hexbin, :hist, :bar, :hline, :vline, :ohlc, :contour
|
:heatmap, :hexbin, :hist, :density, :bar, :hline, :vline, :ohlc, :contour
|
||||||
], _3dTypes)
|
], _3dTypes)
|
||||||
@compat const _typeAliases = Dict(
|
@compat const _typeAliases = Dict(
|
||||||
:n => :none,
|
:n => :none,
|
||||||
@ -29,10 +29,15 @@ const _allTypes = vcat([
|
|||||||
:stems => :sticks,
|
:stems => :sticks,
|
||||||
:dots => :scatter,
|
:dots => :scatter,
|
||||||
:histogram => :hist,
|
:histogram => :hist,
|
||||||
|
:pdf => :density,
|
||||||
:contours => :contours,
|
:contours => :contours,
|
||||||
:line3d => :path3d,
|
:line3d => :path3d,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ishistlike(lt::Symbol) = lt in (:hist, :density)
|
||||||
|
islinelike(lt::Symbol) = lt in (:line, :path, :steppre, :steppost)
|
||||||
|
isheatmaplike(lt::Symbol) = lt in (:heatmap, :hexbin)
|
||||||
|
|
||||||
|
|
||||||
const _allStyles = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
const _allStyles = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
@compat const _styleAliases = Dict(
|
@compat const _styleAliases = Dict(
|
||||||
@ -91,12 +96,12 @@ const _allScales = [:identity, :log, :log2, :log10, :asinh, :sqrt]
|
|||||||
:ln => :log,
|
:ln => :log,
|
||||||
)
|
)
|
||||||
|
|
||||||
supportedAxes(::PlottingPackage) = _allAxes
|
supportedAxes(::PlottingPackage) = [:left]
|
||||||
supportedTypes(::PlottingPackage) = _allTypes
|
supportedTypes(::PlottingPackage) = []
|
||||||
supportedStyles(::PlottingPackage) = _allStyles
|
supportedStyles(::PlottingPackage) = [:solid]
|
||||||
supportedMarkers(::PlottingPackage) = _allMarkers
|
supportedMarkers(::PlottingPackage) = [:none]
|
||||||
supportedScales(::PlottingPackage) = _allScales
|
supportedScales(::PlottingPackage) = [:identity]
|
||||||
subplotSupported(::PlottingPackage) = true
|
subplotSupported(::PlottingPackage) = false
|
||||||
|
|
||||||
supportedAxes() = supportedAxes(backend())
|
supportedAxes() = supportedAxes(backend())
|
||||||
supportedTypes() = supportedTypes(backend())
|
supportedTypes() = supportedTypes(backend())
|
||||||
|
|||||||
@ -126,6 +126,7 @@ function getPyPlotFunction(plt::Plot, axis::Symbol, linetype::Symbol)
|
|||||||
# ax[:set_ylabel](plt.plotargs[:yrightlabel])
|
# ax[:set_ylabel](plt.plotargs[:yrightlabel])
|
||||||
fmap = @compat Dict(
|
fmap = @compat Dict(
|
||||||
:hist => :hist,
|
:hist => :hist,
|
||||||
|
:density => :hist,
|
||||||
:sticks => :bar,
|
:sticks => :bar,
|
||||||
:bar => :bar,
|
:bar => :bar,
|
||||||
:heatmap => :hexbin,
|
:heatmap => :hexbin,
|
||||||
@ -246,13 +247,14 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
plotfunc = getPyPlotFunction(plt, d[:axis], lt)
|
plotfunc = getPyPlotFunction(plt, d[:axis], lt)
|
||||||
|
|
||||||
# we have different args depending on plot type
|
# we have different args depending on plot type
|
||||||
if lt in (:hist, :sticks, :bar)
|
if lt in (:hist, :density, :sticks, :bar)
|
||||||
|
|
||||||
# NOTE: this is unsupported because it does the wrong thing... it shifts the whole axis
|
# NOTE: this is unsupported because it does the wrong thing... it shifts the whole axis
|
||||||
# extra_kwargs[:bottom] = d[:fill]
|
# extra_kwargs[:bottom] = d[:fill]
|
||||||
|
|
||||||
if lt == :hist
|
if ishistlike(lt)
|
||||||
extra_kwargs[:bins] = d[:nbins]
|
extra_kwargs[:bins] = d[:nbins]
|
||||||
|
extra_kwargs[:normed] = lt == :density
|
||||||
else
|
else
|
||||||
extra_kwargs[:linewidth] = (lt == :sticks ? 0.1 : 0.9)
|
extra_kwargs[:linewidth] = (lt == :sticks ? 0.1 : 0.9)
|
||||||
end
|
end
|
||||||
@ -312,7 +314,7 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# do the plot
|
# do the plot
|
||||||
d[:serieshandle] = if lt == :hist
|
d[:serieshandle] = if ishistlike(lt)
|
||||||
plotfunc(d[:y]; extra_kwargs...)[1]
|
plotfunc(d[:y]; extra_kwargs...)[1]
|
||||||
elseif lt == :contour
|
elseif lt == :contour
|
||||||
# NOTE: x/y are backwards in pyplot, so we switch the x and y args (also y is reversed),
|
# NOTE: x/y are backwards in pyplot, so we switch the x and y args (also y is reversed),
|
||||||
@ -607,7 +609,7 @@ end
|
|||||||
function addPyPlotLegend(plt::Plot, ax)
|
function addPyPlotLegend(plt::Plot, ax)
|
||||||
if plt.plotargs[:legend]
|
if plt.plotargs[:legend]
|
||||||
# gotta do this to ensure both axes are included
|
# gotta do this to ensure both axes are included
|
||||||
args = filter(x -> !(x[:linetype] in (:hist,:hexbin,:heatmap,:hline,:vline,:contour, :path3d, :scatter3d)), plt.seriesargs)
|
args = filter(x -> !(x[:linetype] in (:hist,:density,:hexbin,:heatmap,:hline,:vline,:contour, :path3d, :scatter3d)), plt.seriesargs)
|
||||||
if length(args) > 0
|
if length(args) > 0
|
||||||
leg = ax[:legend]([d[:serieshandle] for d in args],
|
leg = ax[:legend]([d[:serieshandle] for d in args],
|
||||||
[d[:label] for d in args],
|
[d[:label] for d in args],
|
||||||
|
|||||||
@ -57,7 +57,9 @@ supportedArgs(::GadflyPackage) = [
|
|||||||
:nlevels,
|
:nlevels,
|
||||||
]
|
]
|
||||||
supportedAxes(::GadflyPackage) = [:auto, :left]
|
supportedAxes(::GadflyPackage) = [:auto, :left]
|
||||||
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :contour]
|
supportedTypes(::GadflyPackage) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
||||||
|
:scatter, :heatmap, :hexbin, :hist, :bar,
|
||||||
|
:hline, :vline, :contour]
|
||||||
supportedStyles(::GadflyPackage) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
supportedStyles(::GadflyPackage) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
supportedMarkers(::GadflyPackage) = vcat(_allMarkers, Shape)
|
supportedMarkers(::GadflyPackage) = vcat(_allMarkers, Shape)
|
||||||
supportedScales(::GadflyPackage) = [:identity, :log, :log2, :log10, :asinh, :sqrt]
|
supportedScales(::GadflyPackage) = [:identity, :log, :log2, :log10, :asinh, :sqrt]
|
||||||
@ -136,7 +138,9 @@ supportedArgs(::PyPlotPackage) = [
|
|||||||
:markeralpha,
|
:markeralpha,
|
||||||
]
|
]
|
||||||
supportedAxes(::PyPlotPackage) = _allAxes
|
supportedAxes(::PyPlotPackage) = _allAxes
|
||||||
supportedTypes(::PyPlotPackage) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :contour, :path3d, :scatter3d]
|
supportedTypes(::PyPlotPackage) = [:none, :line, :path, :steppre, :steppost, :sticks,
|
||||||
|
:scatter, :heatmap, :hexbin, :hist, :density, :bar,
|
||||||
|
:hline, :vline, :contour, :path3d, :scatter3d]
|
||||||
supportedStyles(::PyPlotPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
supportedStyles(::PyPlotPackage) = [:auto, :solid, :dash, :dot, :dashdot]
|
||||||
# supportedMarkers(::PyPlotPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :hexagon]
|
# supportedMarkers(::PyPlotPackage) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :hexagon]
|
||||||
supportedMarkers(::PyPlotPackage) = vcat(_allMarkers, Shape)
|
supportedMarkers(::PyPlotPackage) = vcat(_allMarkers, Shape)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user