Plot¶
-
class
Plot
¶ A plot is an object that is used to group and display one or more graphical elements. The elements that belong to a plot will share the same coordinates space, we will refer to this latter as the model coordinates space.
The plot works by displaying on the screen a region of the model coordinates space. When in
Autolimits
the size of the region will be automatically adjusted to accommodate all the objects contained in the plot. Otherwise the size of the region should be explicitly given using the Plot’s methodPlot::SetLimits()
.When shown on the screen the plot will show all the objects it contains using for each of them a combination of stroking and filling. The plot will also display the X and Y axis with units and labels if the option
ShowUnits
is used.The elements that belongs to a plot are organized in incremental layers of visualization that contains one or more graphical elements. Layers and be added or removed from a plot in an incremental fashion.
Examples of a plot that contains two Path objects, drawn with different colors.
Plot options
-
enumerator
ShowUnits
¶
-
enumerator
AutoLimits
¶
-
enumerator
ClipRegion
¶
Legend Placement
-
enumerator
Left
¶
-
enumerator
Right
¶
-
enumerator
Bottom
¶
-
enumerator
Top
¶
-
Plot
(unsigned flags = 0)¶ Create a new empty plot with options given by
flags
.
-
void
SetTitle
(const char *title)¶ Set the plot’s title.
-
void
SetXAxisTitle
(const char *axis_title)¶ Set the X axis title.
-
void
SetYAxisTitle
(const char *axis_title)¶ Set the Y axis title.
-
void
SetClipMode
(bool flag)¶ Set the clip mode. If true all the pixel drawn for the graphics elements are clipped in the plotting area.
-
void
SetLimits
(float x1, float y1, float x2, float y2)¶ Explicitly set the plotting limits, along the two axis. If the plot is in auto limits mode the limits will be changed when adding new objects.
-
void
SetAxisLabelsAngle
(const Axis &axis, float angle)¶ Set the angle in radians for the labels of the X axis.
-
void
EnableLabelFormat
(const Axis &axis, const char *fmt)¶ Set the format to be used to write the label for the given axis. Follow the same format of the printf function but accepts only specifiers for integer and floating point numbers.
-
void
CommitPendingDraw
()¶ Mark all pending changes as done and they are added to the plot elements. Should not be used as plots includes now a mechanism to perform this operation automatically.
-
void
Add
(Object object, Color stroke_color, float stroke_width, Color fill_color, unsigned flags = property::Fill | property::Stroke)¶ Add a graphical object to the plot by specifying the stroke color, line’s width and fill color.
-
void
AddStroke
(Object object, Color color, float line_width, unsigned flags = property::Stroke)¶ Add a graphical object to the plot by specifying the stroke color, line’s width but without fill. Equivalent to
Plot::Add()
with fill color set tocolor::None
.
-
bool
PushLayer
()¶ Create a new empty layer.
-
bool
PopLayer
()¶ Discard the current layer with all its content. The previous layer will become the current one. If the plot has only one layer the operation has no effect.
-
void
Show
(unsigned width, unsigned height, unsigned flags)¶ Show the plot on the screen with the given width and height. The flags argument is currently unused and should be set to
WindowResize
. It works internally by creating and showing on the screen a window. The functionPlot::Wait()
can be used to wait until the window is closed.
-
void
Wait
()¶ If the plot is shown on the screen, using the
Plot::Show()
, it waits until the window is closed.
-
bool
WriteSvg
(const char *filename, double width, double height)¶ Write the plot as a SVG file with the given filename, width and height.
-
enumerator
Drawing Properties¶
The following are used when adding an element into a plot to specify if should be stroked, filled or possibly both. In addition some properties affect the way the object will be drawn on the screen. The values are meant to be combined using logical bit operators.
-
enumerator
Fill
¶ Draw each closed polygon with a filling color.
-
enumerator
Stroke
¶ Draw the stroking of the path or contour.
-
enumerator
Outline
¶ Only the outline of the path will be drawn, without anti-aliasing.
-
enumerator
Crisp
¶