Class: CTioga2::Graphics::Elements::Subplot
- Inherits:
-
Container
- Object
- TiogaElement
- Container
- CTioga2::Graphics::Elements::Subplot
- Defined in:
- lib/ctioga2/graphics/elements/subplot.rb
Overview
It would be interesting to feature several layers:
It would also be interesting to offer the possibility to
A subplot. It features:
-
inclusion of curves
-
legends
-
a way to set/get its figure boundaries.
background/normal/foreground, that could be addressed just using options to drawing commands
output non-clipped objects.
Instance Attribute Summary collapse
-
#computed_boundaries ⇒ Object
Computed boundaries.
-
#style ⇒ Object
Various stylistic aspects of the plot, as a Styles::PlotStyle object.
-
#user_boundaries ⇒ Object
User-specified boundaries.
Attributes inherited from Container
#elements, #legend_area, #legend_storage, #root_object, #subframe
Attributes inherited from TiogaElement
Instance Method Summary collapse
- #actual_subframe(t) ⇒ Object
-
#count_boundaries? ⇒ Boolean
In general, subplot’s boundaries do not count for the parent plot.
-
#get_boundaries ⇒ Object
Returns the boundaries of the default axes.
-
#get_el_boundaries(el) ⇒ Object
Returns the boundaries that apply for the given curve – it reads the curve’s axes.
-
#initialize(parent, root, style) ⇒ Subplot
constructor
A new instance of Subplot.
-
#set_user_boundaries(axis, bounds) ⇒ Object
Sets the user boundaries for the given (named) axis:.
Methods inherited from Container
#add_element, #add_legend_item, #size
Methods inherited from TiogaElement
Methods included from Log
debug, error, fatal, #format_exception, #identify, info, init_logger, logger, set_level, #spawn, warn
Constructor Details
#initialize(parent, root, style) ⇒ Subplot
Returns a new instance of Subplot.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ctioga2/graphics/elements/subplot.rb', line 51 def initialize(parent, root, style) super(parent, root) @subframe = Types::MarginsBox.new("2.8dy", "2.8dy", "2.8dy", "2.8dy") @subframe = nil # Automatic by default. @style = style || Styles::PlotStyle.new @user_boundaries = {} end |
Instance Attribute Details
#computed_boundaries ⇒ Object
Computed boundaries. It also is a hash axis -> SimpleRange, just as #user_boundaries. Its value is not defined as long as #real_do hasn’t been entered into.
49 50 51 |
# File 'lib/ctioga2/graphics/elements/subplot.rb', line 49 def computed_boundaries @computed_boundaries end |
#style ⇒ Object
Various stylistic aspects of the plot, as a Styles::PlotStyle object.
40 41 42 |
# File 'lib/ctioga2/graphics/elements/subplot.rb', line 40 def style @style end |
#user_boundaries ⇒ Object
User-specified boundaries. It is a hash axis -> SimpleRange, where the axis is a valid return value of PlotStyle#get_axis_key
44 45 46 |
# File 'lib/ctioga2/graphics/elements/subplot.rb', line 44 def user_boundaries @user_boundaries end |
Instance Method Details
#actual_subframe(t) ⇒ Object
91 92 93 |
# File 'lib/ctioga2/graphics/elements/subplot.rb', line 91 def actual_subframe(t) return @subframe || @style.estimate_margins(t) end |
#count_boundaries? ⇒ Boolean
In general, subplot’s boundaries do not count for the parent plot.
97 98 99 |
# File 'lib/ctioga2/graphics/elements/subplot.rb', line 97 def count_boundaries? return false end |
#get_boundaries ⇒ Object
Returns the boundaries of the default axes. Plotting functions may safely assume that they are drawn using these boundaries, unless they asked for being drawn onto different axes.
80 81 82 83 |
# File 'lib/ctioga2/graphics/elements/subplot.rb', line 80 def get_boundaries return get_given_boundaries(style.xaxis_location, style.yaxis_location) end |
#get_el_boundaries(el) ⇒ Object
Returns the boundaries that apply for the given curve – it reads the curve’s axes. #compute_boundaries must have been called beforehand, which means that it will only work from within #real_do.
todo This should not only apply to curves, but to any object. That also means that there should be a way to specify axes for them too.
72 73 74 |
# File 'lib/ctioga2/graphics/elements/subplot.rb', line 72 def get_el_boundaries(el) return get_given_boundaries(* el.location.get_axis_keys(style)) end |
#set_user_boundaries(axis, bounds) ⇒ Object
Sets the user boundaries for the given (named) axis:
86 87 88 89 |
# File 'lib/ctioga2/graphics/elements/subplot.rb', line 86 def set_user_boundaries(axis, bounds) key = @style.get_axis_key(axis) @user_boundaries[key] = Types::SimpleRange.new(bounds) end |