implement axis and grid arguments and corresponding thickness_scaling

This commit is contained in:
Daniel Schwabeneder 2018-06-23 21:47:01 +02:00
parent 865ac52442
commit 624a181b23

View File

@ -162,17 +162,21 @@ function pgf_fillstyle(d, i = 1)
"fill = $cstr, fill opacity=$a" "fill = $cstr, fill opacity=$a"
end end
function pgf_linestyle(d, i = 1) function pgf_linestyle(linewidth::Real, color, alpha = 1, linestyle = "solid")
cstr,a = pgf_color(get_linecolor(d, i)) cstr, a = pgf_color(plot_color(color, alpha))
la = get_linealpha(d, i)
if la != nothing
a = la
end
""" """
color = $cstr, color = $cstr,
draw opacity=$a, draw opacity = $a,
line width=$(pgf_thickness_scaling(d) * get_linewidth(d, i)), line width = $linewidth,
$(get(_pgfplots_linestyles, get_linestyle(d, i), "solid"))""" $(get(_pgfplots_linestyles, linestyle, "solid"))"""
end
function pgf_linestyle(d, i = 1)
lw = pgf_thickness_scaling(d) * get_linewidth(d, i)
lc = get_linecolor(d, i)
la = get_linealpha(d, i)
ls = get_linestyle(d, i)
return pgf_linestyle(lw, lc, la, ls)
end end
function pgf_marker(d, i = 1) function pgf_marker(d, i = 1)
@ -431,6 +435,7 @@ function pgf_axis(sp::Subplot, letter)
push!(style, string(letter, "ticklabels = {}")) push!(style, string(letter, "ticklabels = {}"))
end end
push!(style, string(letter, "tick align = ", (axis[:tick_direction] == :out ? "outside" : "inside"))) push!(style, string(letter, "tick align = ", (axis[:tick_direction] == :out ? "outside" : "inside")))
push!(style, string(letter, " grid style = {", pgf_linestyle(pgf_thickness_scaling(sp) * axis[:gridlinewidth], axis[:foreground_color_grid], axis[:gridalpha], axis[:gridstyle]), "}"))
end end
# framestyle # framestyle
@ -443,7 +448,7 @@ function pgf_axis(sp::Subplot, letter)
if framestyle == :zerolines if framestyle == :zerolines
push!(style, string("extra ", letter, " ticks = 0")) push!(style, string("extra ", letter, " ticks = 0"))
push!(style, string("extra ", letter, " tick labels = ")) push!(style, string("extra ", letter, " tick labels = "))
push!(style, string("extra ", letter, " tick style = {grid = major, major grid style = {color = black, draw opacity=1.0, line width=0.5), solid}}")) push!(style, string("extra ", letter, " tick style = {grid = major, major grid style = {", pgf_linestyle(pgf_thickness_scaling(sp), axis[:foreground_color_axis], 1.0), "}}"))
end end
if !axis[:showaxis] if !axis[:showaxis]
@ -451,6 +456,8 @@ function pgf_axis(sp::Subplot, letter)
end end
if !axis[:showaxis] || framestyle in (:zerolines, :grid, :none) if !axis[:showaxis] || framestyle in (:zerolines, :grid, :none)
push!(style, string(letter, " axis line style = {draw opacity = 0}")) push!(style, string(letter, " axis line style = {draw opacity = 0}"))
else
push!(style, string(letter, " axis line style = {", pgf_linestyle(pgf_thickness_scaling(sp), axis[:foreground_color_axis], 1.0), "}"))
end end
# return the style list and KW args # return the style list and KW args
@ -505,6 +512,8 @@ function _update_plot_object(plt::Plot{PGFPlotsBackend})
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
cstr, a = pgf_color(plot_color(sp[:background_color_legend]))
push!(style, string("legend style = {", pgf_linestyle(pgf_thickness_scaling(sp), sp[:foreground_color_legend], 1.0, "solid"), ",", "fill = $cstr", "}"))
if any(s[:seriestype] == :contour for s in series_list(sp)) if any(s[:seriestype] == :contour for s in series_list(sp))
kw[:view] = "{0}{90}" kw[:view] = "{0}{90}"