Skip to content

Commit

Permalink
winston: linestyle tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nolta committed Mar 18, 2012
1 parent f25432d commit 96c53c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions extras/cairo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ function _set_line_type(ctx::CairoContext, nick::String)
}
# XXX:should be scaled by linewidth
const name2dashes = {
"solid" => Float64[],
"dotted" => [1.,3.],
"dotdashed" => [1.,3.,4.,4.],
"longdashed" => [6.,6.],
Expand Down Expand Up @@ -388,6 +389,7 @@ const __pl_style_func = {
"color" => _set_color,
"linecolor" => _set_color,
"fillcolor" => _set_color,
"linestyle" => _set_line_type,
"linetype" => _set_line_type,
"linewidth" => set_line_width,
"filltype" => set_fill_type,
Expand Down
10 changes: 8 additions & 2 deletions extras/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ end
const chartokens = {
'-' => {"linestyle" => "solid"},
':' => {"linestyle" => "dotted"},
';' => {"linestyle" => "dotdashed"},
'+' => {"symboltype" => "plus"},
'o' => {"symboltype" => "circle"},
'*' => {"symboltype" => "asterisk"},
Expand All @@ -55,7 +56,13 @@ const chartokens = {
function _parse_style(spec::String)
style = HashTable()

# TODO { "--" => "dashed", "-." => "dotdashed" }
for (k,v) in { "--" => "dashed", "-." => "dotdashed" }
splitspec = split(spec, k)
if length(splitspec) > 1
style["linestyle"] = v
spec = join(splitspec)
end
end

for char in spec
if has(chartokens, char)
Expand Down Expand Up @@ -96,7 +103,6 @@ function _plot(p::FramedPlot, args...)
if length(args) > 0 && typeof(args[1]) <: String
style = _parse_style(shift(args))
end
println(style)
if has(style, "linestyle")
add(p, Curve(x, y, style))
end
Expand Down

0 comments on commit 96c53c9

Please sign in to comment.