working on gadfly markers
@ -90,7 +90,7 @@ function generate_markdown(pkgname::Symbol)
|
||||
|
||||
# set up the plotter, and don't show the plots by default
|
||||
plotter!(pkgname)
|
||||
plotDefault!(:show, false)
|
||||
# plotDefault!(:show, false)
|
||||
|
||||
# mkdir if necessary
|
||||
try
|
||||
@ -131,8 +131,8 @@ end
|
||||
|
||||
# run it!
|
||||
# note: generate separately so it's easy to comment out
|
||||
# generate_markdown(:qwt)
|
||||
# generate_markdown(:gadfly)
|
||||
generate_markdown(:qwt)
|
||||
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π)
|
||||
```
|
||||
@ -72,6 +72,16 @@ plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue]
|
||||
|
||||

|
||||
|
||||
### Build plot in pieces
|
||||
|
||||
Start with a base plot...
|
||||
|
||||
```julia
|
||||
plot(rand(100) / 3; reg=true,fillto=0)
|
||||
```
|
||||
|
||||

|
||||
|
||||
###
|
||||
|
||||
and add to it later.
|
||||
|
||||
@ -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: 81 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 57 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: 55 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 101 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 28 KiB |
@ -41,7 +41,7 @@ PLOT_DEFAULTS[:xticks] = true
|
||||
PLOT_DEFAULTS[:yticks] = true
|
||||
PLOT_DEFAULTS[:size] = (600,400)
|
||||
PLOT_DEFAULTS[:windowtitle] = "Plots.jl"
|
||||
PLOT_DEFAULTS[:show] = true
|
||||
# PLOT_DEFAULTS[:show] = true
|
||||
|
||||
PLOT_DEFAULTS[:args] = [] # additional args to pass to the backend
|
||||
PLOT_DEFAULTS[:kwargs] = [] # additional keyword args to pass to the backend
|
||||
|
||||
@ -6,31 +6,6 @@ immutable GadflyPackage <: PlottingPackage end
|
||||
gadfly!() = plotter!(:gadfly)
|
||||
|
||||
|
||||
# # create a blank Gadfly.Plot object
|
||||
# function plot(pkg::GadflyPackage; kw...)
|
||||
# @eval import DataFrames
|
||||
|
||||
# plt = Gadfly.Plot()
|
||||
# plt.mapping = Dict()
|
||||
# plt.data_source = DataFrames.DataFrame()
|
||||
# plt.layers = plt.layers[1:0]
|
||||
|
||||
# # add the title, axis labels, and theme
|
||||
# d = Dict(kw)
|
||||
|
||||
# plt.guides = Gadfly.GuideElement[Gadfly.Guide.xlabel(d[:xlabel]),
|
||||
# Gadfly.Guide.ylabel(d[:ylabel]),
|
||||
# Gadfly.Guide.title(d[:title])]
|
||||
|
||||
# # add the legend?
|
||||
# if d[:legend]
|
||||
# unshift!(plt.guides, Gadfly.Guide.manual_color_key("", AbstractString[], Color[]))
|
||||
# end
|
||||
|
||||
# plt.theme = Gadfly.Theme(background_color = (haskey(d, :background_color) ? d[:background_color] : colorant"white"))
|
||||
|
||||
# Plot(plt, pkg, 0, d, Dict[])
|
||||
# end
|
||||
|
||||
function createGadflyPlotObject(d::Dict)
|
||||
@eval import DataFrames
|
||||
@ -56,35 +31,67 @@ function createGadflyPlotObject(d::Dict)
|
||||
end
|
||||
|
||||
|
||||
function getGeomFromLineType(linetype::Symbol, nbins::Int)
|
||||
linetype == :line && return Gadfly.Geom.line
|
||||
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 == :sticks && return Gadfly.Geom.bar
|
||||
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, nbins::Int)
|
||||
geoms = []
|
||||
# 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 == :line && return [Gadfly.Geom.path]
|
||||
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")
|
||||
|
||||
# handle heatmaps (hexbins) specially
|
||||
if linetype in (:heatmap,:hexbin)
|
||||
push!(geoms, Gadfly.Geom.hexbin(xbincount=nbins, ybincount=nbins))
|
||||
else
|
||||
# else
|
||||
# geoms = []
|
||||
|
||||
# for other linetypes, get the correct Geom
|
||||
push!(geoms, getGeomFromLineType(linetype, nbins))
|
||||
# # 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.point)
|
||||
end
|
||||
# # # 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
|
||||
|
||||
|
||||
|
||||
# serious hack (I think?) to draw my own shapes as annotations... will it work? who knows...
|
||||
function getMarkerGeomsAndGuides(d::Dict)
|
||||
marker = d[:marker]
|
||||
if marker == :none
|
||||
return [],[]
|
||||
elseif marker == :rect
|
||||
sz = d[:markersize] * Gadfly.px
|
||||
# primitive = Gadfly.Compose.PolygonPrimitive()
|
||||
|
||||
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]) - sz/2
|
||||
# ys = collect(d[:y]) - sz/2
|
||||
# w = [d[:markersize] * Gadfly.px]
|
||||
# h = [d[:markersize] * Gadfly.px]
|
||||
return [], [Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), Gadfly.rectangle(xs,ys,sz,sz), Gadfly.fill(d[:markercolor]), Gadfly.stroke(nothing)))]
|
||||
end
|
||||
|
||||
geoms
|
||||
[Gadfly.Geom.point], []
|
||||
end
|
||||
|
||||
|
||||
@ -92,19 +99,29 @@ function addGadflySeries!(gplt, d::Dict)
|
||||
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)
|
||||
append!(gfargs, getLineGeoms(d)) #[:linetype], d[:marker], d[:markercolor], d[:nbins]))
|
||||
|
||||
# handle markers
|
||||
geoms, guides = getMarkerGeomsAndGuides(d)
|
||||
append!(gfargs, geoms)
|
||||
append!(gplt.guides, guides)
|
||||
|
||||
# add a regression line?
|
||||
if d[:reg]
|
||||
push!(gfargs, Gadfly.Geom.smooth(method=:lm))
|
||||
end
|
||||
|
||||
|
||||
# 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
|
||||
theme = Gadfly.Theme(default_color = d[:color],
|
||||
line_width = d[:width] * Gadfly.px,
|
||||
default_point_size = d[:markersize] * Gadfly.px)
|
||||
push!(gfargs, theme)
|
||||
|
||||
# for histograms, set x=y
|
||||
x = d[d[:linetype] == :hist ? :y : :x]
|
||||
|
||||
|
||||