Merge pull request #3430 from ma-laforge/idr_layout

Update plot areas for the given font sizes.
This commit is contained in:
Daniel Schwabeneder 2021-04-28 18:42:14 +02:00 committed by GitHub
commit fd50469e20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -363,37 +363,37 @@ function _inspectdr_setupsubplot(sp::Subplot{InspectDRBackend})
a.title = sp[:title] a.title = sp[:title]
a.xlabel = xaxis[:guide]; a.ylabels = [yaxis[:guide]] a.xlabel = xaxis[:guide]; a.ylabels = [yaxis[:guide]]
l = plot.layout #Modify base layout of new object:
#IMPORTANT: Don't forget to actually register changes l = plot.layout.defaults = deepcopy(InspectDR.defaults.plotlayout)
#(TODO: need to find a better way to set layout properties) #IMPORTANT: Must deepcopy to ensure we don't change layouts of other plots.
l[:frame_canvas].fillcolor = _inspectdr_mapcolor(sp[:background_color_subplot]) #Works because plot uses defaults (not user-overwritten `layout.values`)
l[:frame_canvas] = l[:frame_canvas] #register changes l.frame_canvas.fillcolor = _inspectdr_mapcolor(sp[:background_color_subplot])
l[:frame_data].fillcolor = _inspectdr_mapcolor(sp[:background_color_inside]) l.frame_data.fillcolor = _inspectdr_mapcolor(sp[:background_color_inside])
l[:frame_data] = l[:frame_data] #register changes l.frame_data.line.color = _inspectdr_mapcolor(xaxis[:foreground_color_axis])
l.font_title = InspectDR.Font(sp[:titlefontfamily],
l[:frame_data].line.color = _inspectdr_mapcolor(xaxis[:foreground_color_axis])
l[:frame_data] = l[:frame_data] #register changes
l[:font_title] = InspectDR.Font(sp[:titlefontfamily],
_inspectdr_mapptsize(sp[:titlefontsize]), _inspectdr_mapptsize(sp[:titlefontsize]),
color = _inspectdr_mapcolor(sp[:titlefontcolor]) color = _inspectdr_mapcolor(sp[:titlefontcolor])
) )
#Cannot independently control fonts of axes with InspectDR: #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]), _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]), _inspectdr_mapptsize(xaxis[:tickfontsize]),
color = _inspectdr_mapcolor(xaxis[:tickfontcolor]) color = _inspectdr_mapcolor(xaxis[:tickfontcolor])
) )
l[:enable_legend] = (sp[:legend] != :none) l.enable_legend = (sp[:legend] != :none)
#l[:halloc_legend] = 150 #TODO: compute??? #l.halloc_legend = 150 #TODO: compute???
l[:font_legend] = InspectDR.Font(sp[:legendfontfamily], l.font_legend = InspectDR.Font(sp[:legendfontfamily],
_inspectdr_mapptsize(sp[:legendfontsize]), _inspectdr_mapptsize(sp[:legendfontsize]),
color = _inspectdr_mapcolor(sp[:legendfontcolor]) color = _inspectdr_mapcolor(sp[:legendfontcolor])
) )
l[:frame_legend].fillcolor = _inspectdr_mapcolor(sp[:background_color_legend]) l.frame_legend.fillcolor = _inspectdr_mapcolor(sp[:background_color_legend])
l[:frame_legend] = l[:frame_legend] #register changes
#_round!() ensures values use integer spacings (looks better on screen):
InspectDR._round!(InspectDR.autofit2font!(l, legend_width=10.0)) #10 "em"s wide
return
end end
# called just before updating layout bounding boxes... in case you need to prep # called just before updating layout bounding boxes... in case you need to prep