I didn't put this in a pull request, as it isn't complete, but here is a start for a Winston backend. Basic things work. A couple thoughts:
Anyways, for what it is worth, feel free to use this as you see fit.
immutable WinstonPackage <: PlottingPackage end
winston!() = plotter!(:winston)
# create a blank Winston.Plot object
function plot(pkg::WinstonPackage; kw...)
@eval import DataFrames
d = Dict(kw)
plt = Winston.FramedPlot()
# add the title, axis labels, and theme
Winston.setattr(plt, "xlabel", d[:xlabel])
Winston.setattr(plt, "ylabel", d[:ylabel])
Winston.setattr(plt, "title", d[:title])
# add the legend?
Plot(plt, pkg, 0, d, Dict[])
end
## dictionaries for conversion of Plots.jl names to Winston ones.
const winston_linestyle = Dict(:solid=>"solid",
:dash=>"dash",
:dot=>"dotted",
:dashdot=>"dotdashed",
:dashdotdot=>"dotdashed")
const winston_marker = Dict(:none=>".",
:ellipse=>"circle",
:rect => "square",
:diamond=>"diamond",
:utriangle=>"triangle",
:dtriangle=>"down-triangle",
:cross => "cross",
:xcross => "cross",
:star1 => "asterisk",
:star2 => "filled circle",
:hexagon => "asterisk"
)
# plot one data series
function plot!(::WinstonPackage, plt::Plot; kw...)
d = Dict(kw)
e = Dict()
# axis # :left or :right
# color # can be a string ("red") or a symbol (:red) or a ColorsTypes.jl
e[:color] = d[:color]
# # Colorant (RGB(1,0,0)) or :auto (which lets the package pick)
# label # string or symbol, applies to that line, may go in a legend
# width # width of a line
e[:linewidth] = d[:width]
# linetype # :line, :step, :stepinverted, :sticks, :dots, :none, :heatmap, :hexbin, :hist, :bar
# linestyle # :solid, :dash, :dot, :dashdot, :dashdotdot
e[:kind] = winston_linestyle[d[:linestyle]]
# marker # :none, :ellipse, :rect, :diamond, :utriangle, :dtriangle,
# # :cross, :xcross, :star1, :star2, :hexagon
e[:symbolkind] = winston_marker[d[:marker]]
# markercolor # same choices as `color`, or :match will set the color to be the same as `color`
# markersize # size of the marker
e[:symbolsize] = d[:markersize] / 3
## implement these ...
# heatmap_c # color cutoffs for Qwt heatmaps
# fillto # fillto value for area plots
# yrightlabel # string or symbol, label on the right (y) axis
# size # (Int,Int), resize the enclosing window
# pos # (Int,Int), move the enclosing window to this position
# windowtitle # string or symbol, set the title of the enclosing windowtitle
# screen # Integer, move enclosing window to this screen number (for multiscreen desktops)
# show # true or false, show the plot (in case you don't want the window to pop up right away)
# axis
# color
# label
# add to the legend
# axis
if d[:axis] != :left
warn("Winston only supports one y axis")
end
## do different types based on `linetype`
## should this use dispatch?
## lintype :line, :step, :stepinverted, :sticks, :dots, :none, :heatmap, :hexbin, :hist, :bar
if d[:linetype] == :none
Winston.add(plt.o, Winston.Points(d[:x], d[:y];
[(k,v) for (k,v) in delete!(copy(e), :kind)]...))
if d[:reg]
## add regression line
xs = d[:x]
betahat_0, betahat_1 = [ones(length(xs)) xs] \ d[:y]
ys = betahat_0 + betahat_1 * xs
Winston.add(plt.o, Winston.Curve(xs, ys, kind="dotted"))
end
elseif d[:linetype] == :line
d[:marker] != :none && Winston.add(plt.o, Winston.Points(d[:x], d[:y];
[(k,v) for (k,v) in delete!(copy(e), :kind)]...))
Winston.add(plt.o, Winston.Curve(d[:x], d[:y]; [(k,v) for (k,v) in e]...))
elseif d[:linetype] == :step
fn = Winston.XXX
elseif d[:linetype] == :stepinverted
fn = Winston.XXX
elseif d[:linetype] == :sticks
Winston.add(plt.o, Winston.Stems(d[:x], d[:y]; [(k,v) for (k,v) in e]...))
elseif d[:linetype] == :dots
fn = Winston.XXX
elseif d[:linetype] == :heatmap
fn = Winston.XXX
elseif d[:linetype] == :hexbin
fn = Winston.XXX
elseif d[:linetype] == :hist
hst = hist(d[:y], d[:nbins])
Winston.add(plt.o, Winston.Histogram(hst...; [(k,v) for (k,v) in delete!(copy(e), :nbins)]...))
elseif d[:linetype] == :bar
fn = Winston.XXX
end
plt
end
function savepng(::WinstonPackage, plt::PlottingObject, fn::String, args...)
f = open(fn, "w")
writemime(f, "image/png", plt.o)
close(f)
end
function Base.display(::WinstonPackage, plt::Plot)
Winston.display(plt.o)
end