working on various things

This commit is contained in:
Thomas Breloff 2015-09-24 16:47:30 -04:00
parent d781c437de
commit 0041b034e0
4 changed files with 69 additions and 42 deletions

File diff suppressed because one or more lines are too long

View File

@ -190,7 +190,7 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
# Should ensure from this side that colors which are the same are merged together
push!(gplt.guides[1].labels, d[:label])
push!(gplt.guides[1].colors, d[:marker] == :none ? d[:color] : d[:markercolor])
push!(gplt.guides[1].colors, first(d[:marker] == :none ? d[:color] : d[:markercolor]))
# println("updated legend: ", gplt.guides)
end

View File

@ -49,26 +49,38 @@ function updatePlotItems(plt::Plot{ImmersePackage}, d::Dict)
end
# ----------------------------------------------------------------
# real time updates
# TODO: generalize this and move as much as possible out of here
function getImmerseData(plt::Plot{ImmersePackage}, i::Int)
gplt = plt.o[2]
gplt.layers[end-i+1].mapping
end
# add a new x/y data point to series i
function Base.push!(plt::Plot{ImmersePackage}, i::Int, x::Real, y::Real)
gplt = plt.o[2]
data = gplt.layers[end-i+1].mapping
data = getImmerseData(plt, i)
data[:x] = extendSeriesData(data[:x], x)
data[:y] = extendSeriesData(data[:y], y)
plt
end
# add a new y, and extend x "naturally"
# add a new y, and extend x "naturally" for series i
function Base.push!(plt::Plot{ImmersePackage}, i::Int, y::Real)
gplt = plt.o[2]
data = gplt.layers[end-i+1].mapping
xdata, ydata = xy(plt, i)
data[:x] = extendSeriesData(data[:x]) # this will only work with a UnitRange{Int}!!!
data[:y] = extendSeriesData(data[:y], y)
plt
end
extendSeriesData(v::UnitRange{Int}) = minimum(v):maximum(v)+1
extendSeriesData{T<:Real}(v::AVec{T}, z::Real) = (push!(v, convert(T, z)); v)
function xy(plt::Plot{ImmersePackage}, i::Int)
data = getImmerseData(plt, i)
data[:x], data[:y]
end
# ----------------------------------------------------------------
@ -139,6 +151,7 @@ function Base.display(::PlotsDisplay, plt::Plot{ImmersePackage})
end
Immerse.figure(fig.figno; displayfig = false)
println("about to display")
display(gplt)
end

View File

@ -139,6 +139,11 @@ limsType{T<:Real,S<:Real}(lims::Tuple{T,S}) = :limits
limsType(lims) = :invalid
# used in updating an existing series
extendSeriesData(v::UnitRange{Int}) = minimum(v):maximum(v)+1
extendSeriesData{T<:Real}(v::AVec{T}, z::Real) = (push!(v, convert(T, z)); v)
# Some conversion functions
# note: I borrowed these conversion constants from Compose.jl's Measure
const INCH_SCALAR = 25.4