orientation aliases dir/direction; removed native support for sticks/hline/vline in pyplot; commented out arcdiagram

This commit is contained in:
Thomas Breloff 2016-06-16 17:31:10 -04:00
parent c38e947dc6
commit b0bc68ae8a
3 changed files with 68 additions and 64 deletions

View File

@ -431,6 +431,7 @@ add_aliases(:projection, :proj)
add_aliases(:title_location, :title_loc, :titleloc, :title_position, :title_pos, :titlepos, :titleposition, :title_align, :title_alignment)
add_aliases(:series_annotations, :series_ann, :seriesann, :series_anns, :seriesanns, :series_annotation)
add_aliases(:html_output_format, :format, :fmt, :html_format)
add_aliases(:orientation, :direction, :dir)
# add all pluralized forms to the _keyAliases dict

View File

@ -34,8 +34,8 @@ supported_args(::PyPlotBackend) = merge_with_base_supported([
supported_types(::PyPlotBackend) = [
:path, :steppre, :steppost, :shape,
:scatter, :histogram2d, :hexbin, :histogram,
:bar, :sticks,
:hline, :vline, :heatmap, :pie, :image,
:bar,
:heatmap, :pie, :image,
:contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe
]
supported_styles(::PyPlotBackend) = [:auto, :solid, :dash, :dot, :dashdot]
@ -508,24 +508,24 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
push!(handles, handle)
end
if st == :sticks
extrakw[isvertical(d) ? :width : :height] = 0.0
handle = ax[isvertical(d) ? :bar : :barh](x, y;
label = d[:label],
zorder = plt.n,
color = py_linecolor(d),
edgecolor = py_linecolor(d),
linewidth = d[:linewidth],
align = "center",
extrakw...
)[1]
push!(handles, handle)
end
# if st == :sticks
# extrakw[isvertical(d) ? :width : :height] = 0.0
# handle = ax[isvertical(d) ? :bar : :barh](x, y;
# label = d[:label],
# zorder = plt.n,
# color = py_linecolor(d),
# edgecolor = py_linecolor(d),
# linewidth = d[:linewidth],
# align = "center",
# extrakw...
# )[1]
# push!(handles, handle)
# end
# add markers?
if d[:markershape] != :none && st in (:path, :scatter, :path3d,
:scatter3d, :steppre, :steppost,
:bar, :sticks)
:bar)
extrakw = KW()
if d[:marker_z] == nothing
extrakw[:c] = py_color_fix(py_markercolor(d), x)
@ -539,7 +539,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
end
needs_colorbar = true
end
xyargs = if st in (:bar, :sticks) && !isvertical(d)
xyargs = if st == :bar && !isvertical(d)
(y, x)
else
xyargs
@ -624,17 +624,17 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
needs_colorbar = true
end
if st in (:hline,:vline)
for yi in d[:y]
func = ax[st == :hline ? :axhline : :axvline]
handle = func(yi;
linewidth=d[:linewidth],
color=py_linecolor(d),
linestyle=py_linestyle(st, d[:linestyle])
)
push!(handles, handle)
end
end
# if st in (:hline,:vline)
# for yi in d[:y]
# func = ax[st == :hline ? :axhline : :axvline]
# handle = func(yi;
# linewidth=d[:linewidth],
# color=py_linecolor(d),
# linestyle=py_linestyle(st, d[:linestyle])
# )
# push!(handles, handle)
# end
# end
if st in (:contour, :contour3d)
# z = z.surf'

View File

@ -1039,6 +1039,9 @@ end
# -------------------------------------------------
# TODO: everything below here should be either changed to a
# series recipe or moved to PlotRecipes
"Sparsity plot... heatmap of non-zero values of a matrix"
function spy{T<:Real}(z::AMat{T}; kw...)
@ -1100,56 +1103,56 @@ end
curvecolor(value, min, max, grad) = getColorZ(grad, (value-min)/(max-min))
"Plots a clockwise arc, from source to destiny, colored by weight"
function arc!(source, destiny, weight, min, max, grad)
radius = (destiny - source) / 2
arc = Plots.partialcircle(0, π, 30, radius)
x, y = Plots.unzip(arc)
plot!(x .+ radius .+ source, y, line = (curvecolor(weight, min, max, grad), 0.5, 2), legend=false)
end
# "Plots a clockwise arc, from source to destiny, colored by weight"
# function arc!(source, destiny, weight, min, max, grad)
# radius = (destiny - source) / 2
# arc = Plots.partialcircle(0, π, 30, radius)
# x, y = Plots.unzip(arc)
# plot!(x .+ radius .+ source, y, line = (curvecolor(weight, min, max, grad), 0.5, 2), legend=false)
# end
"""
`arcdiagram(source, destiny, weight[, grad])`
# """
# `arcdiagram(source, destiny, weight[, grad])`
Plots an arc diagram, form `source` to `destiny` (clockwise), using `weight` to determine the colors.
"""
function arcdiagram(source, destiny, weight; kargs...)
# Plots an arc diagram, form `source` to `destiny` (clockwise), using `weight` to determine the colors.
# """
# function arcdiagram(source, destiny, weight; kargs...)
args = KW(kargs)
grad = pop!(args, :grad, ColorGradient([colorant"darkred", colorant"darkblue"]))
# args = KW(kargs)
# grad = pop!(args, :grad, ColorGradient([colorant"darkred", colorant"darkblue"]))
if length(source) == length(destiny) == length(weight)
# if length(source) == length(destiny) == length(weight)
vertices = unique(vcat(source, destiny))
sort!(vertices)
# vertices = unique(vcat(source, destiny))
# sort!(vertices)
xmin, xmax = extrema(vertices)
plot(xlim=(xmin - 0.5, xmax + 0.5), legend=false)
# xmin, xmax = extrema(vertices)
# plot(xlim=(xmin - 0.5, xmax + 0.5), legend=false)
wmin,wmax = extrema(weight)
# wmin,wmax = extrema(weight)
for (i, j, value) in zip(source,destiny,weight)
arc!(i, j, value, wmin, wmax, grad)
end
# for (i, j, value) in zip(source,destiny,weight)
# arc!(i, j, value, wmin, wmax, grad)
# end
scatter!(vertices, zeros(length(vertices)); legend=false, args...)
# scatter!(vertices, zeros(length(vertices)); legend=false, args...)
else
# else
throw(ArgumentError("source, destiny and weight should have the same length"))
# throw(ArgumentError("source, destiny and weight should have the same length"))
end
end
# end
# end
"""
`arcdiagram(mat[, grad])`
# """
# `arcdiagram(mat[, grad])`
Plots an arc diagram from an adjacency matrix, form rows to columns (clockwise),
using the values on the matrix as weights to determine the colors.
Doesn't show edges with value zero if the input is sparse.
For simmetric matrices, only the upper triangular values are used.
"""
arcdiagram{T}(mat::AbstractArray{T,2}; kargs...) = arcdiagram(mat2list(mat)...; kargs...)
# Plots an arc diagram from an adjacency matrix, form rows to columns (clockwise),
# using the values on the matrix as weights to determine the colors.
# Doesn't show edges with value zero if the input is sparse.
# For simmetric matrices, only the upper triangular values are used.
# """
# arcdiagram{T}(mat::AbstractArray{T,2}; kargs...) = arcdiagram(mat2list(mat)...; kargs...)
# ---------------------------------------------------------------------------
# Chord diagram