pgfplots fixes

This commit is contained in:
Thomas Breloff 2016-06-07 01:57:02 -04:00
parent 05fa4a92de
commit d64d3ef101
2 changed files with 19 additions and 17 deletions

View File

@ -132,7 +132,7 @@ function pgf_marker(d::KW)
cstr, a = pgf_color(d[:markercolor], d[:markeralpha]) cstr, a = pgf_color(d[:markercolor], d[:markeralpha])
cstr_stroke, a_stroke = pgf_color(d[:markerstrokecolor], d[:markerstrokealpha]) cstr_stroke, a_stroke = pgf_color(d[:markerstrokecolor], d[:markerstrokealpha])
""" """
mark = $(get(_pgfplots_markers, shape, "o*")), mark = $(get(_pgfplots_markers, shape, "*")),
mark size = $(0.5 * d[:markersize]), mark size = $(0.5 * d[:markersize]),
mark options = { mark options = {
color = $cstr_stroke, draw opacity = $a_stroke, color = $cstr_stroke, draw opacity = $a_stroke,
@ -160,7 +160,7 @@ function pgf_series(sp::Subplot, series::Series)
end end
# add to legend? # add to legend?
if sp.attr[:legend] != :none && should_add_to_legend(series) if sp[:legend] != :none && should_add_to_legend(series)
kw[:legendentry] = d[:label] kw[:legendentry] = d[:label]
end end
@ -198,7 +198,7 @@ end
# ---------------------------------------------------------------- # ----------------------------------------------------------------
function pgf_axis(sp::Subplot, letter) function pgf_axis(sp::Subplot, letter)
axis = sp.attr[Symbol(letter,:axis)] axis = sp[Symbol(letter,:axis)]
style = [] style = []
kw = KW() kw = KW()
@ -250,19 +250,19 @@ function _make_pgf_plot!(plt::Plot)
yshift = $((height(bb) - (bottom(bb))).value)mm, yshift = $((height(bb) - (bottom(bb))).value)mm,
width = $(width(bb).value)mm, width = $(width(bb).value)mm,
height = $(height(bb).value)mm, height = $(height(bb).value)mm,
axis background/.style={fill=$(pgf_color(sp.attr[:background_color_inside])[1])} axis background/.style={fill=$(pgf_color(sp[:background_color_inside])[1])}
""") """)
if sp.attr[:title] != "" if sp[:title] != ""
push!(style, "title = $(sp.attr[:title])") push!(style, "title = $(sp[:title])")
end end
sp.attr[:grid] && push!(style, "grid = major") sp[:grid] && push!(style, "grid = major")
if sp.attr[:aspect_ratio] in (1, :equal) if sp[:aspect_ratio] in (1, :equal)
kw[:axisEqual] = "true" kw[:axisEqual] = "true"
end end
legpos = sp.attr[:legend] legpos = sp[:legend]
if haskey(_pgfplots_legend_pos, legpos) if haskey(_pgfplots_legend_pos, legpos)
kw[:legendPos] = _pgfplots_legend_pos[legpos] kw[:legendPos] = _pgfplots_legend_pos[legpos]
end end

View File

@ -82,8 +82,8 @@ end
function rebuildUnicodePlot!(plt::Plot) function rebuildUnicodePlot!(plt::Plot)
plt.o = [] plt.o = []
for sp in plt.subplots for sp in plt.subplots
xaxis = sp.attr[:xaxis] xaxis = sp[:xaxis]
yaxis = sp.attr[:yaxis] yaxis = sp[:yaxis]
xlim = axis_limits(xaxis) xlim = axis_limits(xaxis)
ylim = axis_limits(yaxis) ylim = axis_limits(yaxis)
@ -97,11 +97,11 @@ function rebuildUnicodePlot!(plt::Plot)
y = Float64[ylim[1]] y = Float64[ylim[1]]
# create a plot window with xlim/ylim set, but the X/Y vectors are outside the bounds # create a plot window with xlim/ylim set, but the X/Y vectors are outside the bounds
width, height = plt.attr[:size] width, height = plt[:size]
o = UnicodePlots.Plot(x, y; o = UnicodePlots.Plot(x, y;
width = width, width = width,
height = height, height = height,
title = sp.attr[:title], title = sp[:title],
xlim = xlim, xlim = xlim,
ylim = ylim ylim = ylim
) )
@ -112,7 +112,7 @@ function rebuildUnicodePlot!(plt::Plot)
# now use the ! functions to add to the plot # now use the ! functions to add to the plot
for series in series_list(sp) for series in series_list(sp)
addUnicodeSeries!(o, series.d, sp.attr[:legend] != :none, xlim, ylim) addUnicodeSeries!(o, series.d, sp[:legend] != :none, xlim, ylim)
end end
# save the object # save the object
@ -246,9 +246,11 @@ end
function _create_backend_figure(plt::Plot{UnicodePlotsBackend}) function _create_backend_figure(plt::Plot{UnicodePlotsBackend})
# do we want to give a new default size? # do we want to give a new default size?
if !haskey(plt.attr, :size) || plt.attr[:size] == default(:size) # if !haskey(plt.attr, :size) || plt.attr[:size] == default(:size)
plt.attr[:size] = (60,20) # plt.attr[:size] = (60,20)
end # end
w, h = plt[:size]
plt.attr[:size] = div(w, 10), div(h, 20)
plt.attr[:color_palette] = [RGB(0,0,0)] plt.attr[:color_palette] = [RGB(0,0,0)]
nothing nothing