Class: Tioga::Legends
- Inherits:
-
Object
- Object
- Tioga::Legends
- Defined in:
- lib/Tioga/Legends.rb
Overview
These are the methods and attributes for plot legends.
Instance Method Summary collapse
-
#legend_alignment ⇒ Object
:call-seq: legend_alignment legend_alignment = an_alignment.
-
#legend_defaults ⇒ Object
:call-seq: legend_defaults legend_defaults = a_dictionary.
-
#legend_height ⇒ Object
:call-seq: legend_height Returns the height (in units of text heights) of the currently saved legend information.
-
#legend_info ⇒ Object
:call-seq: legend_info .
-
#legend_justification ⇒ Object
:call-seq: legend_justification legend_justification = a_justification.
-
#legend_line_dy ⇒ Object
:call-seq: legend_line_dy legend_line_dy = a_float.
-
#legend_line_width ⇒ Object
:call-seq: legend_line_width legend_line_width = a_float.
-
#legend_line_x0 ⇒ Object
:call-seq: legend_line_x0 legend_line_x0 = a_float.
-
#legend_line_x1 ⇒ Object
:call-seq: legend_line_x1 legend_line_x1 = a_float.
-
#legend_scale ⇒ Object
:call-seq: legend_scale legend_scale = a_float.
-
#legend_text_dy ⇒ Object
:call-seq: legend_text_dy legend_text_dy = a_float.
-
#legend_text_width ⇒ Object
:call-seq: legend_text_width legend_text_width = a_float.
-
#legend_text_xstart ⇒ Object
:call-seq: legend_text_xstart legend_text_xstart = a_float.
-
#legend_text_ystart ⇒ Object
:call-seq: legend_text_ystart legend_text_ystart = a_float.
-
#reset_legend_info ⇒ Object
:call-seq: reset_legend_info Clears the current legend information.
-
#save_legend_info(arg) ⇒ Object
:call-seq: save_legend_info(text) save_legend_info(dict).
-
#save_legend_separator(dy) ⇒ Object
Creates a vertical space of dy text heights in the legend.
-
#show_legend(legend_background_function = nil) ⇒ Object
:call-seq: show_legend(legend_background_function=nil) Shows the legend in the current frame.
Instance Method Details
#legend_alignment ⇒ Object
:call-seq:
legend_alignment
legend_alignment = an_alignment
Used as the #alignment value in showing legend text.
182 183 |
# File 'lib/Tioga/Legends.rb', line 182 def legend_alignment end |
#legend_defaults ⇒ Object
:call-seq:
legend_defaults
legend_defaults = a_dictionary
This dictionary holds defaults for show_plot_with_legend
.
75 76 |
# File 'lib/Tioga/Legends.rb', line 75 def legend_defaults end |
#legend_height ⇒ Object
:call-seq:
legend_height
Returns the height (in units of text heights) of the currently saved legend information.
24 25 |
# File 'lib/Tioga/Legends.rb', line 24 def legend_height end |
#legend_info ⇒ Object
:call-seq:
legend_info
The current array of saved legend dictionaries. See save_legend_info for details.
82 83 |
# File 'lib/Tioga/Legends.rb', line 82 def legend_info end |
#legend_justification ⇒ Object
:call-seq:
legend_justification
legend_justification = a_justification
Used as the #justification value in showing legend text.
190 191 |
# File 'lib/Tioga/Legends.rb', line 190 def legend_justification end |
#legend_line_dy ⇒ Object
:call-seq:
legend_line_dy
legend_line_dy = a_float
Each line in a legend is shifted up from the text baseline by this amount measured in units of text height. The corresponding distance in figure coordinates is (legend_line_dy * legend_scale * default_text_height_dy).
112 113 |
# File 'lib/Tioga/Legends.rb', line 112 def legend_line_dy end |
#legend_line_width ⇒ Object
:call-seq:
legend_line_width
legend_line_width = a_float
If this is non-negative, then it is used as the line_width attribute when stroking the lines in a legend. If it is negative, then each legend line is stroked using the value of the line_width attribute at the time the legend information for the entry was saved by save_legend_info.
166 167 |
# File 'lib/Tioga/Legends.rb', line 166 def legend_line_width end |
#legend_line_x0 ⇒ Object
:call-seq:
legend_line_x0
legend_line_x0 = a_float
The x position for the start of lines in a legend, measured in units of text height. The corresponding position in figure coordinates is (legend_line_x0 * legend_scale * default_text_height_dx).
92 93 |
# File 'lib/Tioga/Legends.rb', line 92 def legend_line_x0 end |
#legend_line_x1 ⇒ Object
:call-seq:
legend_line_x1
legend_line_x1 = a_float
The x position for the end of lines in a legend, measured in units of text height. The corresponding position in figure coordinates is (legend_line_x1 * legend_scale * default_text_height_dx).
102 103 |
# File 'lib/Tioga/Legends.rb', line 102 def legend_line_x1 end |
#legend_scale ⇒ Object
:call-seq:
legend_scale
legend_scale = a_float
Used for determining positions in the legend and for showing legend text.
174 175 |
# File 'lib/Tioga/Legends.rb', line 174 def legend_scale end |
#legend_text_dy ⇒ Object
:call-seq:
legend_text_dy
legend_text_dy = a_float
The distance in y to move down after a legend line entry, measured in units of text height. The corresponding distance in figure coordinates is (legend_text_dy * legend_scale * default_text_height_dy).
155 156 |
# File 'lib/Tioga/Legends.rb', line 155 def legend_text_dy end |
#legend_text_width ⇒ Object
:call-seq:
legend_text_width
legend_text_width = a_float
The assumed width of text in a legend, measured in units of text height. The corresponding width in figure coordinates is (legend_text_width * legend_scale * default_text_height_dx). The figure bounding box is expanded if necessary to provide for this much space. If legend_text_width is negative, then the system will provide a default value depending on the placement of the legend.
125 126 |
# File 'lib/Tioga/Legends.rb', line 125 def legend_text_width end |
#legend_text_xstart ⇒ Object
:call-seq:
legend_text_xstart
legend_text_xstart = a_float
The x position for the start of text in a legend, measured in units of text height. The corresponding position in figure coordinates is (legend_text_xstart * legend_scale * default_text_height_dx).
135 136 |
# File 'lib/Tioga/Legends.rb', line 135 def legend_text_xstart end |
#legend_text_ystart ⇒ Object
:call-seq:
legend_text_ystart
legend_text_ystart = a_float
The y position for the start of text in a legend, measured in units of text height. The corresponding position in figure coordinates is (legend_text_ystart * legend_scale * default_text_height_dy).
145 146 |
# File 'lib/Tioga/Legends.rb', line 145 def legend_text_ystart end |
#reset_legend_info ⇒ Object
:call-seq:
reset_legend_info
Clears the current legend information.
13 14 |
# File 'lib/Tioga/Legends.rb', line 13 def reset_legend_info end |
#save_legend_info(arg) ⇒ Object
:call-seq:
save_legend_info(text)
save_legend_info(dict)
Saves information for later use in creating a legend. If called with a string as argument, is equivalent to calling with a dictionary having a single entry with key ‘text’ and value the string.
Dictionary Entries
'text' => a_string # text of the legend
'line_color' => a_color # defaults to self.line_color
'line_width' => a_float # defaults to self.line_width
'line_cap' => a_line_cap # defaults to self.line_cap
'line_type' => a_line_type or 'None' # defaults to self.line_type
'dy' => a_float # defaults to self.legend_text_dy
'marker' => a_marker # defaults to nil
'marker_color' => a_color # defaults to self.line_color
'marker_scale' => a_float # defaults to 0.5
'marker_dict' => a_dictionary # defaults to nil
The dictionary holding the information is appended to the legend_info array. If the ‘marker’ entry is present, then the marker with the given ‘marker_color’ and ‘marker_scale’ will be shown in the middle of the legend line. If the ‘marker_dict’ entry is present, it will have the values for ‘x’ and ‘y’ set to the location of the middle of the legend line and then it will be passed to the show_marker method. This gives you the option of using the full range of marker functionality in legends – perhaps you’d like to use a line marker that is rotated, stretched, filled in one color, and stroked in another! Sometimes you just want to have a marker in the legend without a line; do this by setting line_type to ‘None’.
67 68 |
# File 'lib/Tioga/Legends.rb', line 67 def save_legend_info(arg) end |
#save_legend_separator(dy) ⇒ Object
Creates a vertical space of dy text heights in the legend.
17 18 |
# File 'lib/Tioga/Legends.rb', line 17 def save_legend_separator(dy) end |
#show_legend(legend_background_function = nil) ⇒ Object
:call-seq:
show_legend(legend_background_function=nil)
Shows the legend in the current frame. If given a function arguement, it calls the function with bounds [left, right, top, bottom] for the rectangle where the legend will be shown. You can use this opportunity to provide a background for the legend info and a frame around it too if you’d like.
35 36 |
# File 'lib/Tioga/Legends.rb', line 35 def show_legend(legend_background_function=nil) end |