Class: CTioga::SharedAxisPlot
- Inherits:
-
SubPlot
- Object
- TiogaElement
- Container
- SubPlot
- CTioga::SharedAxisPlot
- Defined in:
- lib/CTioga/structures.rb
Overview
A subplot class for handling plot with alternative axes.
Constant Summary collapse
- BoundaryPositions =
The positions concerned by the axis type in the arrays returned by get_boundaries and the like.
{ :y => [2,3], :x => [0,1] }
Instance Attribute Summary
Attributes inherited from SubPlot
#effective_bounds, #legend_specs, #plot_margins, #plot_style
Attributes inherited from Container
#accept_legend, #disable_legend, #elements, #force_position, #funcalls, #layout, #layout_preferences, #rescale, #root_frame, #show_legend
Attributes inherited from TiogaElement
Instance Method Summary collapse
-
#compute_boundaries ⇒ Object
We use the parents boundary for the shared axis.
-
#get_boundaries ⇒ Object
Report appropriate values for the axes to the parent plot.
-
#initialize(axis = :y, parent = nil) ⇒ SharedAxisPlot
constructor
Creates a subplot of parent which will use alternative axes for axis.
- #private_axis ⇒ Object
-
#shared_axis ⇒ Object
Some pseudo-accessors:.
Methods inherited from SubPlot
#bound_bottom=, #bound_left=, #bound_right=, #bound_top=, #disable_axis, #do, #has_legends?, #inner_frame, #make_main_block, #number, #outer_frame, #set_margin
Methods inherited from Container
#add_elem, #add_funcall, #add_legend_info, #convert_layout, #display_legend?, #has_plots?, #internal_get_boundaries, #make_funcalls, #method_missing
Methods inherited from TiogaElement
Methods included from Log
#identify, #init_logger, #logger, #logger_options, #spawn
Methods included from Debug
#debug_figmaker, #debug_patterns, #debug_puts, #figmaker_options, #test_pattern, #test_pattern_right
Constructor Details
#initialize(axis = :y, parent = nil) ⇒ SharedAxisPlot
Creates a subplot of parent which will use alternative axes for axis. axis is the axis which is not shared !
49 50 51 52 53 54 |
# File 'lib/CTioga/structures.rb', line 49 def initialize(axis = :y, parent = nil) super(:subplot, parent) @axis = axis # We forward all legend information to the parent @accept_legend = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CTioga::Container
Instance Method Details
#compute_boundaries ⇒ Object
We use the parents boundary for the shared axis.
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/CTioga/structures.rb', line 67 def compute_boundaries # First, we compute the boundaries using the standard # Subplot function bounds = super # Then we override the shared values using the parents: parents = parent.compute_boundaries for i in BoundaryPositions[shared_axis] bounds[i] = parents[i] # We use the parents boundaries. end return bounds end |
#get_boundaries ⇒ Object
Report appropriate values for the axes to the parent plot.
58 59 60 61 62 63 64 |
# File 'lib/CTioga/structures.rb', line 58 def get_boundaries bounds = internal_get_boundaries for i in BoundaryPositions[private_axis] bounds[i] = 0.0/0.0 # NaN is ignored end return bounds end |
#private_axis ⇒ Object
43 44 45 |
# File 'lib/CTioga/structures.rb', line 43 def private_axis @axis end |
#shared_axis ⇒ Object
Some pseudo-accessors:
35 36 37 38 39 40 41 |
# File 'lib/CTioga/structures.rb', line 35 def shared_axis if @axis == :y :x else :y end end |