added colorbar_title attr and pyplot impl
This commit is contained in:
parent
ea18b11475
commit
87ab1d9ca4
@ -92,6 +92,7 @@ const _arg_desc = KW(
|
|||||||
:right_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding to the right of the subplot.",
|
:right_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding to the right of the subplot.",
|
||||||
:bottom_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding on the bottom of the subplot.",
|
:bottom_margin => "Measure (multiply by `mm`, `px`, etc) or `:match` (matches `:margin`). Specifies the extra padding on the bottom of the subplot.",
|
||||||
:subplot_index => "Integer. Internal (not set by user). Specifies the index of this subplot in the Plot's `plt.subplot` list.",
|
:subplot_index => "Integer. Internal (not set by user). Specifies the index of this subplot in the Plot's `plt.subplot` list.",
|
||||||
|
:colorbar_title => "String. Title of colorbar.",
|
||||||
|
|
||||||
# axis args
|
# axis args
|
||||||
:guide => "String. Axis guide (label).",
|
:guide => "String. Axis guide (label).",
|
||||||
|
|||||||
@ -248,6 +248,7 @@ const _subplot_defaults = KW(
|
|||||||
:right_margin => :match,
|
:right_margin => :match,
|
||||||
:bottom_margin => :match,
|
:bottom_margin => :match,
|
||||||
:subplot_index => -1,
|
:subplot_index => -1,
|
||||||
|
:colorbar_title => "",
|
||||||
)
|
)
|
||||||
|
|
||||||
const _axis_defaults = KW(
|
const _axis_defaults = KW(
|
||||||
|
|||||||
@ -31,6 +31,7 @@ const _pyplot_attr = merge_with_base_supported([
|
|||||||
:clims,
|
:clims,
|
||||||
:inset_subplots,
|
:inset_subplots,
|
||||||
:dpi,
|
:dpi,
|
||||||
|
:colorbar_title,
|
||||||
])
|
])
|
||||||
const _pyplot_seriestype = [
|
const _pyplot_seriestype = [
|
||||||
:path, :steppre, :steppost, :shape,
|
:path, :steppre, :steppost, :shape,
|
||||||
@ -810,7 +811,9 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
# note: the colorbar axis is positioned independently from the subplot axis
|
# note: the colorbar axis is positioned independently from the subplot axis
|
||||||
fig = plt.o
|
fig = plt.o
|
||||||
cbax = fig[:add_axes]([0.8,0.1,0.03,0.8], label = string(gensym()))
|
cbax = fig[:add_axes]([0.8,0.1,0.03,0.8], label = string(gensym()))
|
||||||
sp.attr[:cbar_handle] = fig[:colorbar](handle; cax = cbax, kw...)
|
cb = fig[:colorbar](handle; cax = cbax, kw...)
|
||||||
|
cb[:set_label](sp[:colorbar_title])
|
||||||
|
sp.attr[:cbar_handle] = cb
|
||||||
sp.attr[:cbar_ax] = cbax
|
sp.attr[:cbar_ax] = cbax
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1057,7 +1060,7 @@ function _update_min_padding!(sp::Subplot{PyPlotBackend})
|
|||||||
# optionally add the width of colorbar labels and colorbar to rightpad
|
# optionally add the width of colorbar labels and colorbar to rightpad
|
||||||
if haskey(sp.attr, :cbar_ax)
|
if haskey(sp.attr, :cbar_ax)
|
||||||
bb = py_bbox(sp.attr[:cbar_handle][:ax][:get_yticklabels]())
|
bb = py_bbox(sp.attr[:cbar_handle][:ax][:get_yticklabels]())
|
||||||
sp.attr[:cbar_width] = _cbar_width + width(bb) + 1mm
|
sp.attr[:cbar_width] = _cbar_width + width(bb) + 1mm + (sp[:colorbar_title] == "" ? 0px : 30px)
|
||||||
rightpad = rightpad + sp.attr[:cbar_width]
|
rightpad = rightpad + sp.attr[:cbar_width]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user