PolygonArray

(Source code, png, hires.png, pdf)

../../_images/PolygonArray.png
class PolygonArray(*args)

Polygon array.

Available constructors:

PolygonArray(legend=’ ‘)

PolygonArray(polygons, legend=’ ‘)

PolygonArray(coordinates, verticesNumber, palette, legend=’ ‘)

Parameters:

legend : str

Legend of the Cloud.

polygons : sequence of Polygon

Sequence of polygons.

coordinates : 2-d sequence of float

The list of coordinates.

verticesNumber : int

Number of vertices.

palette : sequence of str

Polygon colors.

Examples

>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> generator = ot.Normal(2)
>>> size = 5
>>> array = []
>>> palette = ot.Drawable.BuildDefaultPalette(size)
>>> for i in range(size):
...     vertices = generator.getSample(3)
...     array.append(ot.Polygon(vertices, palette[i], palette[size - i - 1]))
>>> graph = ot.Graph('An array of polygons', 'x', 'y', True, '')
>>> graph.add(ot.PolygonArray(array))

Methods

BuildDefaultPalette(size) Build default palette.
ConvertFromHSV(hue, saturation, value) Convert an HSV triplet to a valid hexadecimal code.
ConvertFromHSVA(hue, saturation, value, alpha) Convert an HSVA quadruplet to a valid hexadecimal code.
ConvertFromHSVIntoRGB(hue, saturation, value) Convert an HSV triplet into an RGB triplet.
ConvertFromName(name) Convert a color name to a valid hexadecimal code.
ConvertFromRGB(*args) Convert an RGB triplet to a valid hexadecimal code.
ConvertFromRGBA(*args) Convert an RGBA quadruplet to a valid hexadecimal code.
ConvertToRGB(key) Convert an hexadecimal code into an RGB triplet.
ConvertToRGBA(key) Convert an hexadecimal code into an RGBA quadruplet.
GetValidColors() Return the list of the valid colors of the drawable element.
GetValidFillStyles() Return the list of the valid fill styles of the drawable element.
GetValidLineStyles() Return the list of the valid line styles of the drawable element.
GetValidPointStyles() Return the list of the valid point styles of the drawable element.
clean() Clean all the temporary data created by draw() method.
draw() Generate R command for plotting through R.
getBoundingBox() Accessor to the bounding box of the whole plot.
getCenter() Accessor to the center of the Pie inside the bounding box.
getClassName() Accessor to the object’s name.
getColor() Accessor to the color of the drawable element.
getColorCode() Accessor to the code of the color of the drawable element.
getCoordinates() Accessor to the color of each polygon.
getData() Accessor to the data from which the Drawable is built.
getDrawLabels() Accessor to the indication of data labels’ presence within the drawable element.
getEdgeColor() Accessor to the color of the Polygon edge.
getFillStyle() Accessor to the fill style of the drawable element.
getId() Accessor to the object’s id.
getLabels() Accessor to the labels of data.
getLegend() Accessor to the legend of the drawable element.
getLevels() Accessor to the levels of the Contour.
getLineStyle() Accessor to the line style of the drawable element.
getLineWidth() Accessor to the line width of the drawable element.
getName() Accessor to the object’s name.
getOrigin() Accessor to the origin of the BarPlot.
getPalette() Accessor to the names of the colors used for the Pie.
getPattern() Accessor to the pattern of the Staircase.
getPointCode(key) Accessor to the code of the points style.
getPointStyle() Accessor to the point style of the drawable element.
getRadius() Accessor to the radius of the Pie.
getShadowedId() Accessor to the object’s shadowed id.
getTextAnnotations() Accessor to the annotations of the Text.
getTextPositions() Accessor to the position of annotations.
getVerticesNumber() Accessor to the number of vertices.
getVisibility() Accessor to the object’s visibility state.
getX() Accessor to the first coordinate.
getY() Accessor to the second coordinate.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
setCenter(center) Accessor to the center of the Pie inside the bounding box.
setColor(color) Accessor to the color of the drawable element.
setCoordinatesAndVerticesNumber(coordinates, ...) Accessor to the coordinates of polygons.
setDrawLabels(drawLabels) Accessor to the indication of data labels’ presence within the drawable element.
setFillStyle(fillStyle) Accessor to the fill style of the drawable element.
setLabels(labels) Accessor to the labels of data.
setLegend(legend) Accessor to the legend of the drawable element.
setLevels(levels) Accessor to the levels of the Contour.
setLineStyle(lineStyle) Accessor to the line style of the drawable element.
setLineWidth(lineWidth) Accessor to the line width of the drawable element.
setName(name) Accessor to the object’s name.
setOrigin(origin) Accessor to the origin of the BarPlot.
setPalette(palette) Accessor to the names of the colors used for the Pie.
setPattern(style) Accessor to the pattern of the Staircase.
setPointStyle(pointStyle) Accessor to the point style of the drawable element.
setRadius(radius) Accessor to the radius of the Pie.
setShadowedId(id) Accessor to the object’s shadowed id.
setTextAnnotations(textAnnotations) Accessor to the annotations of the Text.
setTextPositions(textPositions) Accessor to the position of annotations.
setVisibility(visible) Accessor to the object’s visibility state.
setX(x) Accessor to the first coordinate.
setY(y) Accessor to the second coordinate.
__init__(*args)
BuildDefaultPalette(size)

Build default palette.

Parameters:

n : int n > 0

Number of colors needed.

Returns:

listColors : Description

List of n color codes defined according to the default OpenTURNS palette.

Examples

>>> import openturns as ot
>>> print(ot.Drawable().BuildDefaultPalette(4))
[#ff0000,#ccff00,#00ff66,#0066ff]
ConvertFromHSV(hue, saturation, value)

Convert an HSV triplet to a valid hexadecimal code.

Parameters:

hue : float

Hue.

saturation : float

Saturation.

value : float

Value.

Returns:

code : str

Hexadecimal code of the color.

ConvertFromHSVA(hue, saturation, value, alpha)

Convert an HSVA quadruplet to a valid hexadecimal code.

Parameters:

hue : float

Hue.

saturation : float

Saturation.

value : float

Value.

alpha : float

Alpha component.

Returns:

code : str

Hexadecimal code of the color.

ConvertFromHSVIntoRGB(hue, saturation, value)

Convert an HSV triplet into an RGB triplet.

Parameters:

hue : float

Hue.

saturation : float

Saturation.

value : float

Value.

Returns:

RGBComponents : Point

RGB (Red, Green and Blue) components of the color.

ConvertFromName(name)

Convert a color name to a valid hexadecimal code.

Parameters:

name : str

Name of the color. The valid color names are given by the GetValidColors() method.

Returns:

code : str

Hexadecimal code of the color.

Examples

>>> import openturns as ot
>>> print(ot.Drawable.ConvertFromName('red'))
#FF0000
ConvertFromRGB(*args)

Convert an RGB triplet to a valid hexadecimal code.

Parameters:

red, green and blue : either three nonnegative integers or three nonnegative floats

These values are the Red, Green and Blue components of a color, a value of 0 (or 0.0) meaning that the component is absent in the color, a value of 255 (or 1.0) meaning that the component is fully saturated.

Returns:

code : str

Hexadecimal code of the color.

Examples

>>> import openturns as ot
>>> print(ot.Drawable.ConvertFromRGB(255,0,0))
#ff0000
ConvertFromRGBA(*args)

Convert an RGBA quadruplet to a valid hexadecimal code.

Parameters:

red, green and blue : either three nonnegative integers or three nonnegative floats

These values are the Red, Green and Blue components of a color, a value of 0 (or 0.0) meaning that the component is absent in the color, a value of 255 (or 1.0) meaning that the component is fully saturated.

alpha : either nonnegative integer or nonnegative float

Level of the color’s transparency, 0 (or 0.0) meaning that the color is fully transparent and 255 (or 1.0) meaning that the color is fully opaque. The alpha channel is only supported by a few devices, namely the PDF and PNG formats, for the other format the color is fully transparent as soon as its alpha channel is less than 255 (or 1.0).

Returns:

code : str

Hexadecimal code of the color.

Examples

>>> import openturns as ot
>>> print(ot.Drawable.ConvertFromRGBA(255,0,0,255))
#ff0000ff
ConvertToRGB(key)

Convert an hexadecimal code into an RGB triplet.

Parameters:

code : str

Hexadecimal code of the color.

Returns:

RGBComponents : Indices

List containing the RGB (Red, Green and Blue) components of the color. A value of 0 meaning that the component is absent in the color, a value of 255 meaning that the component is fully saturated.

Examples

>>> import openturns as ot
>>> print(ot.Drawable.ConvertToRGB('#ff0000'))
[255,0,0]
ConvertToRGBA(key)

Convert an hexadecimal code into an RGBA quadruplet.

Parameters:

code : str

Hexadecimal code of the color.

Returns:

RGBAComponents : Indices

List containing the RGB (Red, Green and Blue) components. A value of 0 meaning that the component is absent in the color, a value of 255 meaning that the component is fully saturated. It contains also alpha, the level of transparency of the color. Alpha equal to 0 meaning that the color is fully transparent and 255 meaning that the color is fully opaque.

Examples

>>> import openturns as ot
>>> print(ot.Drawable.ConvertToRGBA('#ff0000'))
[255,0,0,255]
GetValidColors()

Return the list of the valid colors of the drawable element.

Returns:

validColors : Description

List of the valid colors of the drawable element.

Examples

>>> import openturns as ot
>>> print(ot.Drawable.GetValidColors()[:5])
[aliceblue,antiquewhite,antiquewhite1,antiquewhite2,antiquewhite3]
GetValidFillStyles()

Return the list of the valid fill styles of the drawable element.

Returns:

validFillStyles : Description

List of the valid fill styles of the drawable element.

Examples

>>> import openturns as ot
>>> print(ot.Drawable.GetValidFillStyles()[:2])
[solid,shaded]
GetValidLineStyles()

Return the list of the valid line styles of the drawable element.

Returns:

validLineStyles : Description

List of the valid line styles of the drawable element.

Examples

>>> import openturns as ot
>>> print(ot.Drawable.GetValidLineStyles())
[blank,solid,dashed,dotted,dotdash,longdash,twodash]
GetValidPointStyles()

Return the list of the valid point styles of the drawable element.

Returns:

validPointStyles : Description

List of the valid point styles of the drawable element.

Examples

>>> import openturns as ot
>>> print(ot.Drawable().GetValidPointStyles()[:5])
[bullet,circle,diamond,dot,fcircle]
clean()

Clean all the temporary data created by draw() method.

draw()

Generate R command for plotting through R.

Returns:

command : str

R command used mainly by the draw method of Graph.

getBoundingBox()

Accessor to the bounding box of the whole plot.

Returns:

boundingBox : Point of dimension 4

Bounding box of the drawable element, which is a rectangle determined by its range along X and its range along Y. The boundingBox is (x_{min}, x_{max}, y_{min}, y_{max}).

getCenter()

Accessor to the center of the Pie inside the bounding box.

Returns:

center : Point

Center of the Pie inside the bounding box.

getClassName()

Accessor to the object’s name.

Returns:

class_name : str

The object class name (object.__class__.__name__).

getColor()

Accessor to the color of the drawable element.

Returns:

color : str

Name of the color of the lines within the drawable element. It can be either the name of a color (e.g. ‘red’) or an hexadecimal code corresponding to the RGB (Red, Green, Blue) components of the color (e.g. ‘#A1B2C3’) or the RGBA (Red, Green, Blue, Alpha) components of the color (e.g. ‘#A1B2C3D4’). The alpha channel is taken into account only by the PDF and PNG formats, for the other format the color is fully transparent as soon as its alpha channel is less than 255 (or 1.0). Use GetValidColors() for a list of available values.

Examples

>>> import openturns as ot
>>> print(ot.Drawable().getColor())
blue
getColorCode()

Accessor to the code of the color of the drawable element.

Returns:

color : str

Hexadecimal code corresponding to the RGB (Red, Green, Blue) components of the color of the lines within the drawable element or the RGBA (Red, Green, Blue, Alpha) components of the color.

See also

setColor, getColor, GetValidColors, setColorCode

Examples

>>> import openturns as ot
>>> print(ot.Drawable().getColorCode())
#0000FF
getCoordinates()

Accessor to the color of each polygon.

Returns:

coordinates : Sample

Polygon coordinates.

getData()

Accessor to the data from which the Drawable is built.

Returns:

data : Sample

Data from which the Drawable is built.

getDrawLabels()

Accessor to the indication of data labels’ presence within the drawable element.

Returns:

drawLabels : bool

True to draw the data labels, False to hide them.

getEdgeColor()

Accessor to the color of the Polygon edge.

Returns:

edgeColor : str

Color of the edge of the Polygon.

getFillStyle()

Accessor to the fill style of the drawable element.

Returns:

fillStyle : str

Fill style of the surfaces within the drawable element. Use GetValidFillStyles() for a list of available values.

Examples

>>> import openturns as ot
>>> print(ot.Drawable().getFillStyle())
solid
getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getLabels()

Accessor to the labels of data.

Returns:

labels : Description

Describes the data within the drawable element.

getLegend()

Accessor to the legend of the drawable element.

Returns:

legend : str

Legend of the drawable element.

getLevels()

Accessor to the levels of the Contour.

Returns:

levels : Point

Different levels where the iso-curves of the Contour will be drawn.

getLineStyle()

Accessor to the line style of the drawable element.

Returns:

lineStyle : str

Style of the line within the drawable element. Use GetValidLineStyles() for a list of available values.

Examples

>>> import openturns as ot
>>> print(ot.Drawable().getLineStyle())
solid
getLineWidth()

Accessor to the line width of the drawable element.

Returns:

lineWidth : int

Width of the line within the drawable element.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getOrigin()

Accessor to the origin of the BarPlot.

Returns:

origin : float

Value where the BarPlot begins.

getPalette()

Accessor to the names of the colors used for the Pie.

Returns:

palette : Description

Names of the colors used for the Pie. It can be either the name of a color (e.g. ‘red’) or an hexadecimal code corresponding to the RGB (Red, Green, Blue) components of the color (e.g. ‘#A1B2C3’) or the RGBA (Red, Green, Blue, Alpha) components of the color (e.g. ‘#A1B2C3D4’).

getPattern()

Accessor to the pattern of the Staircase.

Returns:

pattern : str

Pattern of the Staircase which is ‘S’ or ‘s’. By default the pattern is equal to ‘s’. Going from (x_1, y_1) to (x_2, y_2) with x_1<x_2, pattern=’s‘ moves first horizontal then vertical, whereas pattern=’S’ moves the other way around.

getPointCode(key)

Accessor to the code of the points style.

Parameters:

pointStyle : str

Style point to be changed in code.

Returns:

code : int

Code of the style of the points within the drawable element.

getPointStyle()

Accessor to the point style of the drawable element.

Returns:

pointStyle : str

Style of the points within the drawable element. Use :meth:GetValidPointStyles for a list of available values.

Examples

>>> import openturns as ot
>>> print(ot.Drawable().getPointStyle())
none
getRadius()

Accessor to the radius of the Pie.

Returns:

radius : float

Radius of the Pie.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getTextAnnotations()

Accessor to the annotations of the Text.

Returns:

annotations : Description

Accessor to text annotations.

getTextPositions()

Accessor to the position of annotations.

Parameters:

positions : Indices

Accessor to text position with respect to data coordinates. Text is written below (position=1), above (position=3), to the left (position=2) or to the right (position=4) of data coordinates.

getVerticesNumber()

Accessor to the number of vertices.

Returns:

verticesNumber : int

Number of vertices.

getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

getX()

Accessor to the first coordinate.

Returns:

firstCoord : Sample

Values of the first coordinate.

getY()

Accessor to the second coordinate.

Returns:

secondCoord : Sample

Values of the second coordinate.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

setCenter(center)

Accessor to the center of the Pie inside the bounding box.

Parameters:

center : sequence of float

Center of the Pie inside the bounding box.

setColor(color)

Accessor to the color of the drawable element.

Parameters:

color : str

Describes the color of the lines within the drawable element. It can be either the name of a color (e.g. ‘red’) or an hexadecimal code corresponding to the RGB (Red, Green, Blue) components of the color (e.g. ‘#A1B2C3’) or the RGBA (Red, Green, Blue, Alpha) components of the color (e.g. ‘#A1B2C3D4’). The alpha channel is taken into account only by the PDF and PNG formats, for the other format the color is fully transparent as soon as its alpha channel is less than 255 (or 1.0). Use GetValidColors() for a list of available values.

setCoordinatesAndVerticesNumber(coordinates, verticesNumber)

Accessor to the coordinates of polygons.

Parameters:

coordinates : 2-d sequence of float

The list of coordinates.

verticesNumber : int

number of vertices.

setDrawLabels(drawLabels)

Accessor to the indication of data labels’ presence within the drawable element.

Parameters:

drawLabels : bool

True to draw the data labels, False to hide them.

setFillStyle(fillStyle)

Accessor to the fill style of the drawable element.

Parameters:

fillStyle : str

Fill style of the surfaces within the drawable element. Use GetValidFillStyles() for a list of available values.

setLabels(labels)

Accessor to the labels of data.

Parameters:

labels : sequence of str

Describes the data within the drawable element.

setLegend(legend)

Accessor to the legend of the drawable element.

Parameters:

legend : str

Legend of the drawable element.

setLevels(levels)

Accessor to the levels of the Contour.

Parameters:

levels : sequence of float

Different levels where the iso-curves of the Contour will be drawn.

setLineStyle(lineStyle)

Accessor to the line style of the drawable element.

Parameters:

lineStyle : str

Style of the line within the drawable element. Use GetValidLineStyles() for a list of available values.

setLineWidth(lineWidth)

Accessor to the line width of the drawable element.

Parameters:

lineWidth : positive int

Width of the line within the drawable element.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setOrigin(origin)

Accessor to the origin of the BarPlot.

Parameters:

origin : float

Value where the BarPlot begins.

setPalette(palette)

Accessor to the names of the colors used for the Pie.

Parameters:

palette : sequence of str

Names of the colors used for the Pie. It can be either the name of a color (e.g. ‘red’) or an hexadecimal code corresponding to the RGB (Red, Green, Blue) components of the color (e.g. ‘#A1B2C3’) or the RGBA (Red, Green, Blue, Alpha) components of the color (e.g. ‘#A1B2C3D4’). Use GetValidColors() for a list of available values.

setPattern(style)

Accessor to the pattern of the Staircase.

Parameters:

pattern : str

Pattern of the Staircase which is ‘S’ or ‘s’. By default the pattern is equal to ‘s’. Going from (x_1, y_1) to (x_2, y_2) with x_1<x_2, pattern=’s‘ moves first horizontal then vertical, whereas pattern=’S’ moves the other way around.

setPointStyle(pointStyle)

Accessor to the point style of the drawable element.

Parameters:

pointStyle : str

Style of the points within the drawable element. Use GetValidPointStyles() for a list of available values.

setRadius(radius)

Accessor to the radius of the Pie.

Parameters:

radius : float

Radius of the Pie.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setTextAnnotations(textAnnotations)

Accessor to the annotations of the Text.

Parameters:

annotations : Description

Accessor to text annotations.

setTextPositions(textPositions)

Accessor to the position of annotations.

Parameters:

positions : Indices

Accessor to text position with respect to data coordinates. Text is written below (position=1), above (position=3), to the left (position=2) or to the right (position=4) of data coordinates.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.

setX(x)

Accessor to the first coordinate.

Parameters:

firstCoord : 2-d sequence of float

Values of the first coordinate.

setY(y)

Accessor to the second coordinate.

Parameters:

secondCoord : 2-d sequence of float

Values of the second coordinate.