gadfly marker fixes and examples
@ -132,7 +132,7 @@ end
|
||||
# run it!
|
||||
# note: generate separately so it's easy to comment out
|
||||
# generate_markdown(:qwt)
|
||||
# generate_markdown(:gadfly)
|
||||
generate_markdown(:gadfly)
|
||||
# @osx_only generate_markdown(:unicodeplots)
|
||||
# generate_markdown(:pyplot)
|
||||
generate_markdown(:immerse)
|
||||
|
||||
@ -33,7 +33,7 @@ plot([sin,cos],0,4π)
|
||||
Or make a parametric plot with plot(fx, fy, umin, umax).
|
||||
|
||||
```julia
|
||||
plot(sin,(x->begin # /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π)
|
||||
```
|
||||
|
||||
@ -33,7 +33,7 @@ plot([sin,cos],0,4π)
|
||||
Or make a parametric plot with plot(fx, fy, umin, umax).
|
||||
|
||||
```julia
|
||||
plot(sin,(x->begin # /Users/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π)
|
||||
```
|
||||
|
||||
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 39 KiB |
@ -31,45 +31,18 @@ function createGadflyPlotObject(d::Dict)
|
||||
end
|
||||
|
||||
|
||||
function getGeomsFromLineType(linetype::Symbol)
|
||||
linetype == :line && return [Gadfly.Geom.path]
|
||||
linetype == :dots && return [Gadfly.Geom.point]
|
||||
linetype == :bar && return [Gadfly.Geom.bar]
|
||||
linetype == :step && return [Gadfly.Geom.step]
|
||||
# linetype == :hist && return [Gadfly.Geom.histogram(bincount=nbins)]
|
||||
# linetype == :none && return [Gadfly.Geom.point] # change this? are we usually pairing no line with scatterplots?
|
||||
linetype == :none && return []
|
||||
linetype == :sticks && return [Gadfly.Geom.bar]
|
||||
error("linetype $linetype not currently supported with Gadfly")
|
||||
end
|
||||
|
||||
# function getGeoms(linetype::Symbol, marker::Symbol, markercolor::Colorant, nbins::Int)
|
||||
function getLineGeoms(d::Dict)
|
||||
lt = d[:linetype]
|
||||
lt in (:heatmap,:hexbin) && return [Gadfly.Geom.hexbin(xbincount = d[:nbins], ybincount = d[:nbins])]
|
||||
lt == :hist && return [Gadfly.Geom.histogram(bincount = d[:nbins])]
|
||||
lt == :none && return []
|
||||
lt == :none && return [Gadfly.Geom.path]
|
||||
lt == :line && return [Gadfly.Geom.path]
|
||||
lt == :dots && return [Gadfly.Geom.point]
|
||||
# lt == :dots && return [Gadfly.Geom.point]
|
||||
lt == :bar && return [Gadfly.Geom.bar]
|
||||
lt == :step && return [Gadfly.Geom.step]
|
||||
lt == :sticks && return [Gadfly.Geom.bar]
|
||||
error("linetype $lt not currently supported with Gadfly")
|
||||
|
||||
# else
|
||||
# geoms = []
|
||||
|
||||
# # for other linetypes, get the correct Geom
|
||||
# append!(geoms, getGeomFromLineType(lt, nbins))
|
||||
|
||||
# # # for any marker, add Geom.point
|
||||
# # if marker != :none
|
||||
# # # push!(geoms, Gadfly.Geom.default_point_size)
|
||||
# # push!(geoms, getGadflyMarker(marker, markercolor))
|
||||
# # end
|
||||
# end
|
||||
|
||||
# geoms
|
||||
end
|
||||
|
||||
|
||||
@ -79,22 +52,33 @@ function getMarkerGeomsAndGuides(d::Dict)
|
||||
marker = d[:marker]
|
||||
if marker == :none
|
||||
return [],[]
|
||||
|
||||
# special handling for other marker shapes... gotta create Compose contexts and map them to series points using Guide.Annotation
|
||||
elseif marker == :rect
|
||||
# get the width/height of the square (both are sz)
|
||||
sz = d[:markersize] * Gadfly.px
|
||||
# primitive = Gadfly.Compose.PolygonPrimitive()
|
||||
halfsz = sz/2
|
||||
|
||||
# remap x/y to the corner position of the squares
|
||||
xs = map(z -> Gadfly.Compose.Measure(;cx=z) - halfsz, float(d[:x]))
|
||||
ys = map(z -> Gadfly.Compose.Measure(;cy=z) + halfsz, float(d[:y]))
|
||||
|
||||
# xs = [xi * Gadfly.mm - sz/2 for xi in d[:x]]
|
||||
# ys = [yi * Gadfly.mm - sz/2 for yi in d[:y]]
|
||||
xs = collect(d[:x])
|
||||
ys = collect(d[:y])
|
||||
# xs = collect(d[:x]) - sz/2
|
||||
# ys = collect(d[:y]) - sz/2
|
||||
# w = [d[:markersize] * Gadfly.px]
|
||||
# h = [d[:markersize] * Gadfly.px]
|
||||
# return an Annotation which will add those shapes to each point in the series
|
||||
return [], [Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), Gadfly.rectangle(xs,ys,[sz],[sz]), Gadfly.fill(d[:markercolor]), Gadfly.stroke(nothing)))]
|
||||
|
||||
else
|
||||
# make circles
|
||||
sz = 0.5 * d[:markersize] * Gadfly.px
|
||||
xs = collect(float(d[:x]))
|
||||
ys = collect(float(d[:y]))
|
||||
|
||||
# return an Annotation which will add those shapes to each point in the series
|
||||
return [], [Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), Gadfly.circle(xs,ys,[sz]), Gadfly.fill(d[:markercolor]), Gadfly.stroke(nothing)))]
|
||||
|
||||
end
|
||||
[Gadfly.Geom.point], []
|
||||
|
||||
# otherwise just return a Geom.point
|
||||
# [Gadfly.Geom.point], []
|
||||
end
|
||||
|
||||
|
||||
@ -114,26 +98,27 @@ function addGadflySeries!(gplt, d::Dict)
|
||||
push!(gfargs, Gadfly.Geom.smooth(method=:lm))
|
||||
end
|
||||
|
||||
# add to the legend
|
||||
if length(gplt.guides) > 0 && isa(gplt.guides[1], Gadfly.Guide.ManualColorKey)
|
||||
push!(gplt.guides[1].labels, d[:label])
|
||||
push!(gplt.guides[1].colors, d[:marker] == :none ? d[:color] : d[:markercolor])
|
||||
end
|
||||
|
||||
# if we haven't added any geoms, we're probably just going to use annotations?
|
||||
isempty(gfargs) && return
|
||||
|
||||
# # if we haven't added any geoms, we're probably just going to use annotations?
|
||||
# isempty(gfargs) && return
|
||||
|
||||
|
||||
# set theme: color, line width, and point size
|
||||
line_width = d[:width] * (d[:linetype] == :none ? 0 : 1) * Gadfly.px # 0 width when we don't show a line
|
||||
theme = Gadfly.Theme(default_color = d[:color],
|
||||
line_width = d[:width] * Gadfly.px,
|
||||
default_point_size = d[:markersize] * Gadfly.px)
|
||||
line_width = line_width,
|
||||
default_point_size = 0.5 * d[:markersize] * Gadfly.px)
|
||||
push!(gfargs, theme)
|
||||
|
||||
# for histograms, set x=y
|
||||
x = d[d[:linetype] == :hist ? :y : :x]
|
||||
|
||||
# add to the legend
|
||||
if length(gplt.guides) > 0 && isa(gplt.guides[1], Gadfly.Guide.ManualColorKey)
|
||||
push!(gplt.guides[1].labels, d[:label])
|
||||
push!(gplt.guides[1].colors, d[:color])
|
||||
end
|
||||
|
||||
if d[:axis] != :left
|
||||
warn("Gadly only supports one y axis")
|
||||
end
|
||||
@ -162,46 +147,6 @@ function plot!(::GadflyPackage, plt::Plot; kw...)
|
||||
plt
|
||||
end
|
||||
|
||||
# # plot one data series
|
||||
# function plot!(::GadflyPackage, plt::Plot; kw...)
|
||||
# d = Dict(kw)
|
||||
|
||||
# gfargs = []
|
||||
|
||||
# # add the Geoms
|
||||
# append!(gfargs, getGeoms(d[:linetype], d[:marker], d[:nbins]))
|
||||
|
||||
# # set color, line width, and point size
|
||||
# theme = Gadfly.Theme(default_color = d[:color],
|
||||
# line_width = d[:width] * Gadfly.px,
|
||||
# default_point_size = d[:markersize] * Gadfly.px)
|
||||
# push!(gfargs, theme)
|
||||
|
||||
# # add a regression line?
|
||||
# if d[:reg]
|
||||
# push!(gfargs, Gadfly.Geom.smooth(method=:lm))
|
||||
# end
|
||||
|
||||
# # for histograms, set x=y
|
||||
# x = d[d[:linetype] == :hist ? :y : :x]
|
||||
|
||||
# # add to the legend
|
||||
# if length(plt.o.guides) > 0 && isa(plt.o.guides[1], Gadfly.Guide.ManualColorKey)
|
||||
# push!(plt.o.guides[1].labels, d[:label])
|
||||
# push!(plt.o.guides[1].colors, d[:color])
|
||||
# end
|
||||
|
||||
# if d[:axis] != :left
|
||||
# warn("Gadly only supports one y axis")
|
||||
# end
|
||||
|
||||
# # save the kw args
|
||||
# push!(plt.seriesargs, d)
|
||||
|
||||
# # add the layer to the Gadfly.Plot
|
||||
# prepend!(plt.o.layers, Gadfly.layer(unique(gfargs)..., d[:args]...; x = x, y = d[:y], d[:kwargs]...))
|
||||
# plt
|
||||
# end
|
||||
|
||||
function Base.display(::GadflyPackage, plt::Plot)
|
||||
display(plt.o)
|
||||
@ -235,21 +180,10 @@ end
|
||||
|
||||
# create the underlying object (each backend will do this differently)
|
||||
function buildSubplotObject!(::GadflyPackage, subplt::Subplot)
|
||||
# i = 0
|
||||
# rows = []
|
||||
# for rowcnt in subplt.layout.rowcounts
|
||||
# push!(rows, Gadfly.hstack([getGadflyContext(plt.plotter, plt) for plt in subplt.plts[(1:rowcnt) + i]]...))
|
||||
# i += rowcnt
|
||||
# end
|
||||
# subplt.o = Gadfly.vstack(rows...)
|
||||
# subplt.o = buildGadflySubplotContext(subplt)
|
||||
subplt.o = nothing
|
||||
end
|
||||
|
||||
|
||||
function Base.display(::GadflyPackage, subplt::Subplot)
|
||||
# getGadflyContext!(subplt.plotter, subplt)
|
||||
# display(subplt.o)
|
||||
println("HERE"); sleep(2)
|
||||
display(buildGadflySubplotContext(subplt))
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@ immerse!() = plotter!(:immerse)
|
||||
|
||||
|
||||
function createImmerseFigure(d::Dict)
|
||||
println("Creating immerse figure: ", d)
|
||||
# println("Creating immerse figure: ", d)
|
||||
w,h = d[:size]
|
||||
figidx = Immerse.figure(; name = d[:windowtitle], width = w, height = h)
|
||||
Immerse.Figure(figidx)
|
||||
@ -36,7 +36,6 @@ function plot!(::ImmersePackage, plt::Plot; kw...)
|
||||
end
|
||||
|
||||
function Base.display(::ImmersePackage, plt::Plot)
|
||||
println("disp1")
|
||||
|
||||
fig, gplt = plt.o
|
||||
if fig == nothing
|
||||
@ -65,6 +64,10 @@ end
|
||||
# -------------------------------
|
||||
|
||||
|
||||
# function buildSubplotObject!(::ImmersePackage, subplt::Subplot)
|
||||
# end
|
||||
|
||||
|
||||
# create the underlying object
|
||||
function buildSubplotObject!(::ImmersePackage, subplt::Subplot)
|
||||
subplt.o = (nothing, nothing)
|
||||
@ -72,7 +75,6 @@ end
|
||||
|
||||
|
||||
function Base.display(::ImmersePackage, subplt::Subplot)
|
||||
println("disp2")
|
||||
|
||||
fig, gctx = subplt.o
|
||||
if fig == nothing
|
||||
|
||||