Format .jl files [skip ci] (#3896)
Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>
This commit is contained in:
parent
2e67e84361
commit
804fab45ad
@ -597,15 +597,25 @@ function _update_plot_object(plt::Plot{PGFPlotsBackend})
|
||||
cstr, bg_alpha = pgf_color(plot_color(sp[:legend_background_color]))
|
||||
fg_alpha = alpha(plot_color(sp[:legend_foreground_color]))
|
||||
|
||||
push!(style, string(
|
||||
push!(
|
||||
style,
|
||||
string(
|
||||
"legend style = {",
|
||||
pgf_linestyle(pgf_thickness_scaling(sp), sp[:legend_foreground_color], fg_alpha, "solid", ), ",",
|
||||
pgf_linestyle(
|
||||
pgf_thickness_scaling(sp),
|
||||
sp[:legend_foreground_color],
|
||||
fg_alpha,
|
||||
"solid",
|
||||
),
|
||||
",",
|
||||
"fill = $cstr,",
|
||||
"fill opacity = $bg_alpha,",
|
||||
"text opacity = $(alpha(plot_color(sp[:legend_font_color]))),",
|
||||
"font = ", pgf_font(sp[:legend_font_pointsize], pgf_thickness_scaling(sp)),
|
||||
"font = ",
|
||||
pgf_font(sp[:legend_font_pointsize], pgf_thickness_scaling(sp)),
|
||||
"}",
|
||||
))
|
||||
),
|
||||
)
|
||||
|
||||
if any(s[:seriestype] == :contour for s in series_list(sp))
|
||||
kw[:view] = "{0}{90}"
|
||||
|
||||
@ -1100,7 +1100,8 @@ function gr_add_legend(sp, leg, viewport_plotarea)
|
||||
ms = first(series[:markersize])
|
||||
msw = first(series[:markerstrokewidth])
|
||||
s, sw = if ms > 0
|
||||
0.8 * sp[:legend_font_pointsize], 0.8 * sp[:legend_font_pointsize] * msw / ms
|
||||
0.8 * sp[:legend_font_pointsize],
|
||||
0.8 * sp[:legend_font_pointsize] * msw / ms
|
||||
else
|
||||
0, 0.8 * sp[:legend_font_pointsize] * msw / 8
|
||||
end
|
||||
|
||||
@ -395,24 +395,28 @@ function _inspectdr_setupsubplot(sp::Subplot{InspectDRBackend})
|
||||
l.frame_canvas.fillcolor = _inspectdr_mapcolor(sp[:background_color_subplot])
|
||||
l.frame_data.fillcolor = _inspectdr_mapcolor(sp[:background_color_inside])
|
||||
l.frame_data.line.color = _inspectdr_mapcolor(xaxis[:foreground_color_axis])
|
||||
l.font_title = InspectDR.Font(sp[:titlefontfamily],
|
||||
l.font_title = InspectDR.Font(
|
||||
sp[:titlefontfamily],
|
||||
_inspectdr_mapptsize(sp[:titlefontsize]),
|
||||
color = _inspectdr_mapcolor(sp[:titlefontcolor])
|
||||
color = _inspectdr_mapcolor(sp[:titlefontcolor]),
|
||||
)
|
||||
#Cannot independently control fonts of axes with InspectDR:
|
||||
l.font_axislabel = InspectDR.Font(xaxis[:guidefontfamily],
|
||||
l.font_axislabel = InspectDR.Font(
|
||||
xaxis[:guidefontfamily],
|
||||
_inspectdr_mapptsize(xaxis[:guidefontsize]),
|
||||
color = _inspectdr_mapcolor(xaxis[:guidefontcolor])
|
||||
color = _inspectdr_mapcolor(xaxis[:guidefontcolor]),
|
||||
)
|
||||
l.font_ticklabel = InspectDR.Font(xaxis[:tickfontfamily],
|
||||
l.font_ticklabel = InspectDR.Font(
|
||||
xaxis[:tickfontfamily],
|
||||
_inspectdr_mapptsize(xaxis[:tickfontsize]),
|
||||
color = _inspectdr_mapcolor(xaxis[:tickfontcolor])
|
||||
color = _inspectdr_mapcolor(xaxis[:tickfontcolor]),
|
||||
)
|
||||
l.enable_legend = (sp[:legend_position] != :none)
|
||||
#l.halloc_legend = 150 #TODO: compute???
|
||||
l.font_legend = InspectDR.Font(sp[:legend_font_family],
|
||||
l.font_legend = InspectDR.Font(
|
||||
sp[:legend_font_family],
|
||||
_inspectdr_mapptsize(sp[:legend_font_pointsize]),
|
||||
color = _inspectdr_mapcolor(sp[:legend_font_color])
|
||||
color = _inspectdr_mapcolor(sp[:legend_font_color]),
|
||||
)
|
||||
l.frame_legend.fillcolor = _inspectdr_mapcolor(sp[:legend_background_color])
|
||||
#_round!() ensures values use integer spacings (looks better on screen):
|
||||
|
||||
@ -166,8 +166,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
sp_width > 0 * mm ? push!(axis_opt, "width" => string(axis_width)) : nothing
|
||||
sp_height > 0 * mm ? push!(axis_opt, "height" => string(axis_height)) : nothing
|
||||
for letter in (:x, :y, :z)
|
||||
if letter != :z ||
|
||||
RecipesPipeline.is3d(sp)
|
||||
if letter != :z || RecipesPipeline.is3d(sp)
|
||||
pgfx_axis!(axis_opt, sp, letter)
|
||||
end
|
||||
end
|
||||
@ -256,11 +255,9 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend})
|
||||
axis,
|
||||
PGFPlotsX.LegendEntry(
|
||||
PGFPlotsX.Options(
|
||||
"font" => pgfx_font(
|
||||
legtfont.pointsize,
|
||||
pgfx_thickness_scaling(sp),
|
||||
),
|
||||
"text" => legtfont.color
|
||||
"font" =>
|
||||
pgfx_font(legtfont.pointsize, pgfx_thickness_scaling(sp)),
|
||||
"text" => legtfont.color,
|
||||
),
|
||||
string("\\hspace{-.6cm}{\\textbf{", sp[:legend_title], "}}"),
|
||||
false,
|
||||
@ -388,7 +385,8 @@ function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, o
|
||||
end
|
||||
end
|
||||
if i == 1 &&
|
||||
series[:subplot][:legend_position] != :none && pgfx_should_add_to_legend(series)
|
||||
series[:subplot][:legend_position] != :none &&
|
||||
pgfx_should_add_to_legend(series)
|
||||
pgfx_filllegend!(series_opt, opt)
|
||||
end
|
||||
end
|
||||
@ -822,12 +820,15 @@ function pgfx_get_legend_style(sp)
|
||||
"fill" => cstr,
|
||||
"fill opacity" => a,
|
||||
"text opacity" => alpha(plot_color(sp[:legend_font_color])),
|
||||
"font" => pgfx_font(
|
||||
sp[:legend_font_pointsize],
|
||||
pgfx_thickness_scaling(sp),
|
||||
),
|
||||
"font" => pgfx_font(sp[:legend_font_pointsize], pgfx_thickness_scaling(sp)),
|
||||
"text" => plot_color(sp[:legend_font_color]),
|
||||
"cells" => PGFPlotsX.Options("anchor" => get((left = "west", right = "east", hcenter = "center"), legfont.halign, "west")),
|
||||
"cells" => PGFPlotsX.Options(
|
||||
"anchor" => get(
|
||||
(left = "west", right = "east", hcenter = "center"),
|
||||
legfont.halign,
|
||||
"west",
|
||||
),
|
||||
),
|
||||
pgfx_get_legend_pos(sp[:legend_position])...,
|
||||
)
|
||||
end
|
||||
@ -957,7 +958,6 @@ end
|
||||
pgfx_legend_col(s::Symbol) = s == :horizontal ? -1 : 1
|
||||
pgfx_legend_col(n) = n
|
||||
|
||||
|
||||
function pgfx_linestyle(plotattributes, i = 1)
|
||||
lw = pgfx_thickness_scaling(plotattributes) * get_linewidth(plotattributes, i)
|
||||
lc = single_color(get_linecolor(plotattributes, i))
|
||||
@ -1454,7 +1454,8 @@ end
|
||||
# to fit ticks, tick labels, guides, colorbars, etc.
|
||||
function _update_min_padding!(sp::Subplot{PGFPlotsXBackend})
|
||||
leg = sp[:legend_position]
|
||||
if leg in (:best, :outertopright, :outerright, :outerbottomright) || (leg isa Tuple && leg[1] >= 1)
|
||||
if leg in (:best, :outertopright, :outerright, :outerbottomright) ||
|
||||
(leg isa Tuple && leg[1] >= 1)
|
||||
sp.minpad = (0mm, 0mm, 5mm, 0mm)
|
||||
else
|
||||
sp.minpad = (0mm, 0mm, 0mm, 0mm)
|
||||
|
||||
@ -1679,11 +1679,21 @@ function py_add_legend(plt::Plot, sp::Subplot, ax)
|
||||
leg."set_zorder"(1000)
|
||||
if sp[:legend_title] !== nothing
|
||||
leg."set_title"(sp[:legend_title])
|
||||
PyPlot.plt."setp"(leg."get_title"(), color = py_color(sp[:legend_title_font_color]), family = sp[:legend_title_font_family], fontsize = py_thickness_scale(plt, sp[:legend_title_font_pointsize]))
|
||||
PyPlot.plt."setp"(
|
||||
leg."get_title"(),
|
||||
color = py_color(sp[:legend_title_font_color]),
|
||||
family = sp[:legend_title_font_family],
|
||||
fontsize = py_thickness_scale(plt, sp[:legend_title_font_pointsize]),
|
||||
)
|
||||
end
|
||||
|
||||
for txt in leg."get_texts"()
|
||||
PyPlot.plt."setp"(txt, color = py_color(sp[:legend_font_color]), family = sp[:legend_font_family], fontsize = py_thickness_scale(plt, sp[:legend_font_pointsize]))
|
||||
PyPlot.plt."setp"(
|
||||
txt,
|
||||
color = py_color(sp[:legend_font_color]),
|
||||
family = sp[:legend_font_family],
|
||||
fontsize = py_thickness_scale(plt, sp[:legend_font_pointsize]),
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1239,15 +1239,30 @@ const _examples = PlotExample[
|
||||
The bars' baseline may be specified as `fillto`.
|
||||
Each may be scalar, or a vector spcifying one value per bar.
|
||||
""",
|
||||
[:(
|
||||
[
|
||||
:(
|
||||
begin
|
||||
plot(bar([-1,0,2,3], [1,3,6,2],
|
||||
fill_z = 4:-1:1, alpha = [1, 0.2, 0.8, 0.5], label = "", bar_width = 1:4),
|
||||
bar(rand(5), bar_width=1.2, alpha=0.8,
|
||||
plot(
|
||||
bar(
|
||||
[-1, 0, 2, 3],
|
||||
[1, 3, 6, 2],
|
||||
fill_z = 4:-1:1,
|
||||
alpha = [1, 0.2, 0.8, 0.5],
|
||||
label = "",
|
||||
bar_width = 1:4,
|
||||
),
|
||||
bar(
|
||||
rand(5),
|
||||
bar_width = 1.2,
|
||||
alpha = 0.8,
|
||||
color = [:lightsalmon, :tomato, :crimson, :firebrick, :darkred],
|
||||
fillto=0:-0.1:-0.4, label="reds"))
|
||||
fillto = 0:-0.1:-0.4,
|
||||
label = "reds",
|
||||
),
|
||||
)
|
||||
end
|
||||
)],
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@ -517,7 +517,7 @@ end
|
||||
end
|
||||
# Each segment is 6 elements long, including the NaN separator.
|
||||
# There is no trailing NaN, so the last repetition is dropped.
|
||||
plotattributes[k] = @view repeat(v; inner=6)[1:end-1]
|
||||
plotattributes[k] = @view repeat(v; inner = 6)[1:(end - 1)]
|
||||
end
|
||||
end
|
||||
()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user