x/y/z ticklabel rotation; new supported graphs using heatmap

This commit is contained in:
Thomas Breloff 2016-05-03 17:14:52 -04:00
parent 00f3d450f9
commit 3c09921cbd
4 changed files with 29 additions and 18 deletions

View File

@ -180,6 +180,9 @@ _plotDefaults[:zticks] = :auto
_plotDefaults[:xscale] = :identity
_plotDefaults[:yscale] = :identity
_plotDefaults[:zscale] = :identity
_plotDefaults[:xrotation] = 0
_plotDefaults[:yrotation] = 0
_plotDefaults[:zrotation] = 0
_plotDefaults[:xflip] = false
_plotDefaults[:yflip] = false
_plotDefaults[:zflip] = false
@ -304,15 +307,18 @@ add_aliases(:annotation, :ann, :anns, :annotate, :annotations)
add_aliases(:xlabel, :xlab, :xl)
add_aliases(:xlims, :xlim, :xlimit, :xlimits)
add_aliases(:xticks, :xtick)
add_aliases(:xrotation, :xrot, :xr)
add_aliases(:ylabel, :ylab, :yl)
add_aliases(:ylims, :ylim, :ylimit, :ylimits)
add_aliases(:yticks, :ytick)
add_aliases(:yrightlabel, :yrlab, :yrl, :ylabel2, :y2label, :ylab2, :y2lab, :ylabr, :ylabelright)
add_aliases(:yrightlims, :yrlim, :yrlimit, :yrlimits)
add_aliases(:yrightticks, :yrtick)
add_aliases(:yrotation, :yrot, :yr)
add_aliases(:zlabel, :zlab, :zl)
add_aliases(:zlims, :zlim, :zlimit, :zlimits)
add_aliases(:zticks, :ztick)
add_aliases(:zrotation, :zrot, :zr)
add_aliases(:legend, :leg, :key)
add_aliases(:colorbar, :cb, :cbar, :colorkey)
add_aliases(:smooth, :regression, :reg)

View File

@ -20,10 +20,10 @@ supportedArgs(::PyPlotBackend) = [
:n, :nc, :nr, :layout,
:smooth,
:title, :windowtitle, :show, :size,
:x, :xlabel, :xlims, :xticks, :xscale, :xflip,
:y, :ylabel, :ylims, :yticks, :yscale, :yflip,
:x, :xlabel, :xlims, :xticks, :xscale, :xflip, :xrotation,
:y, :ylabel, :ylims, :yticks, :yscale, :yflip, :yrotation,
:axis, :yrightlabel,
:z, :zlabel, :zlims, :zticks, :zscale, :zflip,
:z, :zlabel, :zlims, :zticks, :zscale, :zflip, :zrotation,
:z,
:tickfont, :guidefont, :legendfont,
:grid, :legend, :colorbar,
@ -885,7 +885,8 @@ function _update_plot(plt::Plot{PyPlotBackend}, d::KW)
# handle each axis in turn
for letter in ("x", "y", "z")
axis, scale, lims, ticks, flip, lab = axis_symbols(letter, "axis", "scale", "lims", "ticks", "flip", "label")
axis, scale, lims, ticks, flip, lab, rotation =
axis_symbols(letter, "axis", "scale", "lims", "ticks", "flip", "label", "rotation")
haskey(ax, axis) || continue
haskey(d, scale) && applyPyPlotScale(ax, d[scale], letter)
haskey(d, lims) && addPyPlotLims(ax, d[lims], letter)
@ -898,6 +899,7 @@ function _update_plot(plt::Plot{PyPlotBackend}, d::KW)
tmpax[axis][:label][:set_fontsize](guidesz)
for lab in tmpax[symbol("get_", letter, "ticklabels")]()
lab[:set_fontsize](ticksz)
haskey(d, rotation) && lab[:set_rotation](d[rotation])
end
if get(d, :grid, false)
fgcolor = getPyPlotColor(plt.plotargs[:foreground_color_grid])

View File

@ -109,7 +109,7 @@ function plot!(plt::Plot, args...; kw...)
# add title, axis labels, ticks, etc
if !haskey(d, :subplot)
# merge!(plt.plotargs, d)
merge!(plt.plotargs, d)
# handlePlotColors(plt.backend, plt.plotargs)
dumpdict(plt.plotargs, "Updating plot items")
_update_plot(plt, plt.plotargs)

View File

@ -542,19 +542,22 @@ end
function supportGraph(allvals, func)
vals = reverse(sort(allvals))
bs = sort(backends())
x = ASCIIString[]
y = ASCIIString[]
for val in vals
for b in bs
supported = func(Plots._backend_instance(b))
if val in supported
push!(x, string(b))
push!(y, string(val))
end
end
x, y = map(string, bs), map(string, vals)
nx, ny = map(length, (x,y))
z = zeros(nx, ny)
for i=1:nx, j=1:ny
supported = func(Plots._backend_instance(bs[i]))
z[i,j] = float(vals[j] in supported) * (0.4i/nx+0.6)
end
n = length(vals)
scatter(x, y, m=:rect, ms=10, size=(300,100+18*n), leg=false)
heatmap(x, y, z,
color = ColorGradient([:white, :darkblue]),
line = (1, :black),
leg = false,
size = (50nx+50, 35ny+100),
xlim = (0.5, nx+0.5),
ylim = (0.5, ny+0.5),
xrotation = 60,
aspect_ratio = :equal)
end
supportGraphArgs() = supportGraph(_allArgs, supportedArgs)
@ -568,7 +571,7 @@ function dumpSupportGraphs()
for func in (supportGraphArgs, supportGraphTypes, supportGraphStyles,
supportGraphMarkers, supportGraphScales, supportGraphAxes)
plt = func()
png(joinpath(Pkg.dir("ExamplePlots"), "docs", "examples", "img", "supported", "$(string(func))"))
png(Pkg.dir("ExamplePlots", "docs", "examples", "img", "supported", "$(string(func))"))
end
end