Pie

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

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

Pie.

Available constructors:

Pie(data)

Pie(data, labels)

Pie(data, labels, center, radius, palette)

Parameters
datasequence of float

Sequence giving the percentiles of the pie.

labelssequence of str

Names of each group. If not specified, by default equal to the description of the probabilistic input vector.

centersequence of float

Center of the pie inside the bounding box. If not specified, by default it is (0,0).

radiuspositive float

Radius of the pie. If not specified, by default it is 1.

palettesequence of str

Names of the colors. If not specified, colors are successively taken from the list given by buildDefaultPalette(), in the same order.

Examples

>>> import openturns as ot
>>> # Create the Pie
>>> myPie = ot.Pie([0.4, 0.3, 0.2, 0.1], ['a0', 'a1', 'a2', 'a3'])
>>> # Create an empty graph
>>> myGraph = ot.Graph('A Pie', ' ', ' ', True, '')
>>> myGraph.add(myPie)

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.

IsValidColorPalette(palette)

Test the validity of a color palette.

buildDefaultLabels(self)

Build default labels by taking the percentiles.

buildDefaultPalette(self)

Build default palette.

clean(self)

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

draw(self)

Generate R command for plotting through R.

getBoundingBox(self)

Accessor to the bounding box of the whole plot.

getCenter(self)

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

getClassName(self)

Accessor to the object’s name.

getColor(self)

Accessor to the color of the drawable element.

getColorCode(self)

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

getData(self)

Accessor to the data from which the Drawable is built.

getDrawLabels(self)

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

getEdgeColor(self)

Accessor to the color of the Polygon edge.

getFillStyle(self)

Accessor to the fill style of the drawable element.

getId(self)

Accessor to the object’s id.

getLabels(self)

Accessor to the labels of data.

getLegend(self)

Accessor to the legend of the drawable element.

getLevels(self)

Accessor to the levels of the Contour.

getLineStyle(self)

Accessor to the line style of the drawable element.

getLineWidth(self)

Accessor to the line width of the drawable element.

getName(self)

Accessor to the object’s name.

getOrigin(self)

Accessor to the origin of the BarPlot.

getPalette(self)

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

getPaletteAsNormalizedRGBA(self)

Accessor to the Red, Green, Blue, Alpha components of the palette on a unit scale.

getPattern(self)

Accessor to the pattern of the Staircase.

getPointCode(self, key)

Accessor to the code of the points style.

getPointStyle(self)

Accessor to the point style of the drawable element.

getRadius(self)

Accessor to the radius of the Pie.

getShadowedId(self)

Accessor to the object’s shadowed id.

getTextAnnotations(self)

Accessor to the annotations of the Text.

getTextPositions(self)

Accessor to the position of annotations.

getTextSize(self)

Accessor to the text size.

getVisibility(self)

Accessor to the object’s visibility state.

getX(self)

Accessor to the first coordinate.

getY(self)

Accessor to the second coordinate.

hasName(self)

Test if the object is named.

hasVisibleName(self)

Test if the object has a distinguishable name.

setCenter(self, center)

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

setColor(self, color)

Accessor to the color of the drawable element.

setDrawLabels(self, drawLabels)

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

setFillStyle(self, fillStyle)

Accessor to the fill style of the drawable element.

setLabels(self, labels)

Accessor to the labels of data.

setLegend(self, legend)

Accessor to the legend of the drawable element.

setLevels(self, levels)

Accessor to the levels of the Contour.

setLineStyle(self, lineStyle)

Accessor to the line style of the drawable element.

setLineWidth(self, lineWidth)

Accessor to the line width of the drawable element.

setName(self, name)

Accessor to the object’s name.

setOrigin(self, origin)

Accessor to the origin of the BarPlot.

setPalette(self, palette)

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

setPattern(self, style)

Accessor to the pattern of the Staircase.

setPointStyle(self, pointStyle)

Accessor to the point style of the drawable element.

setRadius(self, radius)

Accessor to the radius of the Pie.

setShadowedId(self, id)

Accessor to the object’s shadowed id.

setTextAnnotations(self, textAnnotations)

Accessor to the annotations of the Text.

setTextPositions(self, textPositions)

Accessor to the position of annotations.

setTextSize(self, size)

Accessor to the text size.

setVisibility(self, visible)

Accessor to the object’s visibility state.

setX(self, x)

Accessor to the first coordinate.

setY(self, y)

Accessor to the second coordinate.

__init__(self, \*args)

Initialize self. See help(type(self)) for accurate signature.

static BuildDefaultPalette(size)

Build default palette.

Parameters
nint n > 0

Number of colors needed.

Returns
listColorsDescription

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

Notes

The colors are generated in the HSV space, with H (the hue) varying in a number of different values given by ‘Drawable-DefaultPalettePhase’ in ResourceMap and V (the value) being decreased linearly at each cycle of the hue.

Examples

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

Convert an HSV triplet to a valid hexadecimal code.

Parameters
huefloat

Hue.

saturationfloat

Saturation.

valuefloat

Value.

Returns
codestr

Hexadecimal code of the color.

static ConvertFromHSVA(hue, saturation, value, alpha)

Convert an HSVA quadruplet to a valid hexadecimal code.

Parameters
huefloat

Hue.

saturationfloat

Saturation.

valuefloat

Value.

alphafloat

Alpha component.

Returns
codestr

Hexadecimal code of the color.

static ConvertFromHSVIntoRGB(hue, saturation, value)

Convert an HSV triplet into an RGB triplet.

Parameters
huefloat

Hue.

saturationfloat

Saturation.

valuefloat

Value.

Returns
RGBComponentsPoint

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

static ConvertFromName(name)

Convert a color name to a valid hexadecimal code.

Parameters
namestr

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

Returns
codestr

Hexadecimal code of the color.

Examples

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

Convert an RGB triplet to a valid hexadecimal code.

Parameters
red, green and blueeither 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
codestr

Hexadecimal code of the color.

Examples

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

Convert an RGBA quadruplet to a valid hexadecimal code.

Parameters
red, green and blueeither 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.

alphaeither 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
codestr

Hexadecimal code of the color.

Examples

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

Convert an hexadecimal code into an RGB triplet.

Parameters
codestr

Hexadecimal code of the color.

Returns
RGBComponentsIndices

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]
static ConvertToRGBA(key)

Convert an hexadecimal code into an RGBA quadruplet.

Parameters
codestr

Hexadecimal code of the color.

Returns
RGBAComponentsIndices

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]
static GetValidColors()

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

Returns
validColorsDescription

List of the valid colors of the drawable element.

Examples

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

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

Returns
validFillStylesDescription

List of the valid fill styles of the drawable element.

Examples

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

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

Returns
validLineStylesDescription

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]
static GetValidPointStyles()

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

Returns
validPointStylesDescription

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]
static IsValidColorPalette(palette)

Test the validity of a color palette.

Parameters
palettesequence of str

Names of the colors.

Returns
validitybool

True if palette is valid or False otherwise.

Examples

>>> import openturns as ot
>>> pie = ot.Pie([0.5,0.2,0.3])
>>> print(pie.IsValidColorPalette(['#ff0000','#ccff00','#00ff66']))
True
>>> print(pie.IsValidColorPalette(['green','red','darkorange']))
True
>>> print(pie.IsValidColorPalette(['green','red','darkpink']))
False
buildDefaultLabels(self)

Build default labels by taking the percentiles.

buildDefaultPalette(self)

Build default palette.

Call BuildDefaultPalette() with n the size of data as argument.

clean(self)

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

draw(self)

Generate R command for plotting through R.

Returns
commandstr

R command used mainly by the draw method of Graph.

getBoundingBox(self)

Accessor to the bounding box of the whole plot.

Returns
boundingBoxInterval of dimension 2

Bounding box of the drawable element

getCenter(self)

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

Returns
centerPoint

Center of the Pie inside the bounding box.

getClassName(self)

Accessor to the object’s name.

Returns
class_namestr

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

getColor(self)

Accessor to the color of the drawable element.

Returns
colorstr

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(self)

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

Returns
colorstr

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
getData(self)

Accessor to the data from which the Drawable is built.

Returns
dataSample

Data from which the Drawable is built.

getDrawLabels(self)

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

Returns
drawLabelsbool

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

getEdgeColor(self)

Accessor to the color of the Polygon edge.

Returns
edgeColorstr

Color of the edge of the Polygon.

getFillStyle(self)

Accessor to the fill style of the drawable element.

Returns
fillStylestr

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(self)

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

getLabels(self)

Accessor to the labels of data.

Returns
labelsDescription

Describes the data within the drawable element.

getLegend(self)

Accessor to the legend of the drawable element.

Returns
legendstr

Legend of the drawable element.

getLevels(self)

Accessor to the levels of the Contour.

Returns
levelsPoint

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

getLineStyle(self)

Accessor to the line style of the drawable element.

Returns
lineStylestr

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(self)

Accessor to the line width of the drawable element.

Returns
lineWidthfloat

Width of the line within the drawable element.

getName(self)

Accessor to the object’s name.

Returns
namestr

The name of the object.

getOrigin(self)

Accessor to the origin of the BarPlot.

Returns
originfloat

Value where the BarPlot begins.

getPalette(self)

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

Returns
paletteDescription

Names of the colors used for the Drawable. 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’).

getPaletteAsNormalizedRGBA(self)

Accessor to the Red, Green, Blue, Alpha components of the palette on a unit scale.

Returns
normalizedRGBAPaletteSample

Sample of the four components of each color of the palette on a unit [0,1] scale.

getPattern(self)

Accessor to the pattern of the Staircase.

Returns
patternstr

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(self, key)

Accessor to the code of the points style.

Parameters
pointStylestr

Style point to be changed in code.

Returns
codeint

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

getPointStyle(self)

Accessor to the point style of the drawable element.

Returns
pointStylestr

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(self)

Accessor to the radius of the Pie.

Returns
radiusfloat

Radius of the Pie.

getShadowedId(self)

Accessor to the object’s shadowed id.

Returns
idint

Internal unique identifier.

getTextAnnotations(self)

Accessor to the annotations of the Text.

Returns
annotationsDescription

Accessor to text annotations.

getTextPositions(self)

Accessor to the position of annotations.

Returns
positionsIndices

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.

getTextSize(self)

Accessor to the text size.

Returns
sizefloat

Size of the Text.

Notes

The default value is 0.75.

getVisibility(self)

Accessor to the object’s visibility state.

Returns
visiblebool

Visibility flag.

getX(self)

Accessor to the first coordinate.

Returns
firstCoordSample

Values of the first coordinate.

getY(self)

Accessor to the second coordinate.

Returns
secondCoordSample

Values of the second coordinate.

hasName(self)

Test if the object is named.

Returns
hasNamebool

True if the name is not empty.

hasVisibleName(self)

Test if the object has a distinguishable name.

Returns
hasVisibleNamebool

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

setCenter(self, center)

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

Parameters
centersequence of float

Center of the Pie inside the bounding box.

setColor(self, color)

Accessor to the color of the drawable element.

Parameters
colorstr

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.

setDrawLabels(self, drawLabels)

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

Parameters
drawLabelsbool

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

setFillStyle(self, fillStyle)

Accessor to the fill style of the drawable element.

Parameters
fillStylestr

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

setLabels(self, labels)

Accessor to the labels of data.

Parameters
labelssequence of str

Describes the data within the drawable element.

setLegend(self, legend)

Accessor to the legend of the drawable element.

Parameters
legendstr

Legend of the drawable element.

setLevels(self, levels)

Accessor to the levels of the Contour.

Parameters
levelssequence of float

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

setLineStyle(self, lineStyle)

Accessor to the line style of the drawable element.

Parameters
lineStylestr

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

setLineWidth(self, lineWidth)

Accessor to the line width of the drawable element.

Parameters
lineWidthpositive float

Width of the line within the drawable element.

setName(self, name)

Accessor to the object’s name.

Parameters
namestr

The name of the object.

setOrigin(self, origin)

Accessor to the origin of the BarPlot.

Parameters
originfloat

Value where the BarPlot begins.

setPalette(self, palette)

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

Parameters
palettesequence 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(self, style)

Accessor to the pattern of the Staircase.

Parameters
patternstr

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(self, pointStyle)

Accessor to the point style of the drawable element.

Parameters
pointStylestr

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

setRadius(self, radius)

Accessor to the radius of the Pie.

Parameters
radiusfloat

Radius of the Pie.

setShadowedId(self, id)

Accessor to the object’s shadowed id.

Parameters
idint

Internal unique identifier.

setTextAnnotations(self, textAnnotations)

Accessor to the annotations of the Text.

Parameters
annotationsDescription

Accessor to text annotations.

setTextPositions(self, textPositions)

Accessor to the position of annotations.

Parameters
positionsIndices

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.

setTextSize(self, size)

Accessor to the text size.

Parameters
sizefloat

Size of the Text.

Notes

The default value is 0.75.

setVisibility(self, visible)

Accessor to the object’s visibility state.

Parameters
visiblebool

Visibility flag.

setX(self, x)

Accessor to the first coordinate.

Parameters
firstCoord2-d sequence of float

Values of the first coordinate.

setY(self, y)

Accessor to the second coordinate.

Parameters
secondCoord2-d sequence of float

Values of the second coordinate.