Plot

class Plot(*args, **kwargs)

Bases: pybind11_object

This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window which contains between 1 and 4 graphics. Each one contains a desired number of curves.

Warning

This class is only available if one of the display functionalities (X11, GDI, GTK, OpenCV or Direct3D) is available. In visp3/core/vpConfig.h header file, you should have VISP_HAVE_DISPLAY define.

The example below shows how to use the vpPlot class. An other example provided in tutorial-ibvs-plotter.cpp and described in tutorial-plotter shows how to use this class to plot in real-time some curves during an image-based visual servo.

#include <visp3/gui/vpPlot.h>

int main ()
{
#if defined(VISP_HAVE_DISPLAY)
  // Create a window (700 by 700) at position (100, 200) with two graphics
  vpPlot A(2, 700, 700, 100, 200, "Curves...");

  // The first graphic contains 1 curve and the second graphic contains 2 curves
  A.initGraph(0,1); A.initGraph(1,2);

  // The color of the curve in the first graphic is red
  A.setColor(0,0,vpColor::red);
  // The first curve in the second graphic is green
  A.setColor(1,0,vpColor::green);
  // The second curve in the second graphic is blue
  A.setColor(1,1,vpColor::blue);

  // Add the point (0,0) in the first graphic
  A.plot(0,0,0,0);

  // Add the point (0,1) to the first curve of the second graphic
  A.plot(1,0,0,1);

  // Add the point (0,2) to the second curve of the second graphic
  A.plot(1,1,0,2);

  for (int i = 0; i < 50; ++i) {
    // Add the point (i,sin(i*pi/10) in the first graphic
    A.plot(0,0,i,sin(i*M_PI/10));

    // Add the point (i,1) to the first curve of the second graphic
    A.plot(1,0,i,1);

    // Add the point (i,2) to the second curve of the second graphic
    A.plot(1,1,i,2);
  }

  return 0;
#endif
}

Overloaded function.

  1. __init__(self: visp._visp.gui.Plot) -> None

Default constructor.

Needs then a call to init() .

  1. __init__(self: visp._visp.gui.Plot, nbGraph: int, height: int = 700, width: int = 700, x: int = -1, y: int = -1, title: str = ) -> None

This constructor creates a new window where the curves will be drawn. The number of graphics in the window must be set.

Warning

You can modify the default window size, but this is not advised.

Warning

Under Unix, when X11 is used to display the curves, the default font is set to “-adobe-times-medium-i-normal–10-100-75-75-p-52-iso8859-*”. Note that you can chose an other one using “xfontsel”.

Parameters:
height

Height of the window.

width

Width of the window.

x

The window is set at position x,y (column index, row index).

y

The window is set at position x,y (column index, row index).

title

Window title.

Methods

__init__

Overloaded function.

getPixelValue

This method displays the coordinates of the point pointed by the mouse pointer.

init

Creates a new window where the curves will be drawn.

initGraph

Function which enables to initialize the number of curves which belongs to a graphic.

initRange

Overloaded function.

navigate

This method allows to change the point of view with the mouse if you have a 3D graphic.

plot

Overloaded function.

resetPointList

Overloaded function.

saveData

This function enables to save in a text file all the plotted points of a graphic.

setColor

This function enables you to choose the color used to draw a given curve.

setFont

Set the font of the characters.

setGraphThickness

This function enables you to choose the thickness used to draw all the curves belonging to a given graphic.

setGridThickness

This function enables you to choose the thickness used to draw the grid and the axis of a given graphic.

setLegend

Sets the legend of a curve.

setThickness

This function enables you to choose the thickness used to draw a given curve.

setTitle

Sets the title of a graphic.

setUnitX

Sets the unit system of the x axis.

setUnitY

Sets the unit system of the y axis.

setUnitZ

Sets the unit system of the z axis.

Inherited Methods

Operators

__doc__

__init__

Overloaded function.

__module__

Attributes

I

__annotations__

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.gui.Plot) -> None

Default constructor.

Needs then a call to init() .

  1. __init__(self: visp._visp.gui.Plot, nbGraph: int, height: int = 700, width: int = 700, x: int = -1, y: int = -1, title: str = ) -> None

This constructor creates a new window where the curves will be drawn. The number of graphics in the window must be set.

Warning

You can modify the default window size, but this is not advised.

Warning

Under Unix, when X11 is used to display the curves, the default font is set to “-adobe-times-medium-i-normal–10-100-75-75-p-52-iso8859-*”. Note that you can chose an other one using “xfontsel”.

Parameters:
height

Height of the window.

width

Width of the window.

x

The window is set at position x,y (column index, row index).

y

The window is set at position x,y (column index, row index).

title

Window title.

getPixelValue(self, block: bool) None

This method displays the coordinates of the point pointed by the mouse pointer.

Parameters:
block: bool

If true, this method waits a click.

init(self: visp._visp.gui.Plot, nbGraph: int, height: int = 700, width: int = 700, x: int = -1, y: int = -1, title: str =) None

Creates a new window where the curves will be drawn. The number of graphics in the window must be set.

Warning

You can modify the default window size, but this is not advised.

Parameters:
height

Height of the window.

width

Width of the window.

x

The window is set at position x,y (column index, row index).

y

The window is set at position x,y (column index, row index).

title

Window title.

initGraph(self, graphNum: int, curveNbr: int) None

Function which enables to initialize the number of curves which belongs to a graphic.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

curveNbr: int

The number of curves belonging to the graphic

initRange(*args, **kwargs)

Overloaded function.

  1. initRange(self: visp._visp.gui.Plot, graphNum: int, xmin: float, xmax: float, ymin: float, ymax: float) -> None

This method enables to set the initial range of the selected graphic.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

xmin

The initial minimum value along the x axis given in the user coordinates.

xmax

The initial maximum value along the x axis given in the user coordinates.

ymin

The initial minimum value along the y axis given in the user coordinates.

ymax

The initial maximum value along the y axis given in the user coordinates.

  1. initRange(self: visp._visp.gui.Plot, graphNum: int, xmin: float, xmax: float, ymin: float, ymax: float, zmin: float, zmax: float) -> None

This method enables to set the initial range of the selected graphic.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

xmin

The initial minimum value along the x axis given in the user coordinates.

xmax

The initial maximum value along the x axis given in the user coordinates.

ymin

The initial minimum value along the y axis given in the user coordinates.

ymax

The initial maximum value along the y axis given in the user coordinates.

zmin

The initial minimum value along the z axis given in the user coordinates.

zmax

The initial maximum value along the z axis given in the user coordinates.

navigate(self) None

This method allows to change the point of view with the mouse if you have a 3D graphic. The navigation is performed using the mouse.

  • A click on left mouse button allows rotations

  • A click on middle mouse button allows zoom

  • A click on right mouse button quit the infinite navigation loop.

plot(*args, **kwargs)

Overloaded function.

  1. plot(self: visp._visp.gui.Plot, graphNum: int, curveNum: int, x: float, y: float) -> None

This function enables you to add a new point in the curve. This point is drawn with the parameters of the curve.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

curveNum

The index of the curve in the list of the curves belonging to the graphic.

x

The coordinate of the new point along the x axis and given in the user unit system.

y

The coordinate of the new point along the y axis and given in the user unit system.

  1. plot(self: visp._visp.gui.Plot, graphNum: int, x: float, v_y: visp._visp.core.ColVector) -> None

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

x

The coordinate of the new points along the x axis and given in the user unit system.

v_y

y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

  1. plot(self: visp._visp.gui.Plot, graphNum: int, x: float, v_y: visp._visp.core.RowVector) -> None

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

x

The coordinate of the new points along the x axis and given in the user unit system.

v_y

y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

  1. plot(self: visp._visp.gui.Plot, graphNum: int, x: float, v_y: visp._visp.core.PoseVector) -> None

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

x

The coordinate of the new points along the x axis and given in the user unit system.

v_y

y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

  1. plot(self: visp._visp.gui.Plot, graphNum: int, x: float, v_y: visp._visp.core.TranslationVector) -> None

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

x

The coordinate of the new points along the x axis and given in the user unit system.

v_y

y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

  1. plot(self: visp._visp.gui.Plot, graphNum: int, x: float, v_y: visp._visp.core.RotationVector) -> None

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

x

The coordinate of the new points along the x axis and given in the user unit system.

v_y

y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

  1. plot(self: visp._visp.gui.Plot, graphNum: int, curveNum: int, x: float, y: float, z: float) -> visp._visp.core.MouseButton.MouseButtonType

This function enables you to add a new point in the curve. This point is drawn with the parameters of the curve.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

curveNum

The index of the curve in the list of the curves belonging to the graphic.

x

The coordinate of the new point along the x axis and given in the user unit system.

y

The coordinate of the new point along the y axis and given in the user unit system.

z

The coordinate of the new point along the z axis and given in the user unit system.

  1. plot(self: visp._visp.gui.Plot, graphNum: int, x: float, v_y: visp._visp.core.ColVector, v_z: visp._visp.core.ColVector) -> visp._visp.core.MouseButton.MouseButtonType

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

x

The coordinate of the new points along the x axis and given in the user unit system.

v_y

y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

v_z

z coordinates vector. The coordinates of the new points along the z axis and given in the user unit system.

resetPointList(*args, **kwargs)

Overloaded function.

  1. resetPointList(self: visp._visp.gui.Plot, graphNum: int) -> None

This method enables to erase the list of points stored for the graphic number \(graphNum\) .

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

  1. resetPointList(self: visp._visp.gui.Plot, graphNum: int, curveNum: int) -> None

This method enables to erase the list of points stored for the curve number \(curveNum\) contained in the graphic number \(graphNum\) .

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

curveNum

The index of the curve in the list of the curves belonging to the graphic.

saveData(self: visp._visp.gui.Plot, graphNum: int, dataFile: str, title_prefix: str =) None

This function enables to save in a text file all the plotted points of a graphic.

The content of the file is the following:

  • The first line of the text file is the graphic title prefixed by title_prefix .

  • Then the successive points coordinates (x, y, z) are given for each curve. If the graphic has two curves:

    • the first column corresponds to the x axis of the first curve

    • the second column corresponds to the y axis of the first curve

    • the third column corresponds to the z axis of the first curve

    • the fourth column corresponds to the x axis of the second curve

    • the fifth column corresponds to the y axis of the second curve

    • the sixth column corresponds to the z axis of the second curve

The columns are delimited thanks to tabulations.

Parameters:
graphNum

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

dataFile

Name of the text file.

title_prefix

Prefix introduced in the first line of the saved file. To exploit a posteriori the resulting curves:

  • with gnuplot, set title_prefix to “# “.

  • with Matlab, set title_prefix to “% “.

setColor(self, graphNum: int, curveNum: int, color: visp._visp.core.Color) None

This function enables you to choose the color used to draw a given curve.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

curveNum: int

The index of the curve in the list of the curves belonging to the graphic.

color: visp._visp.core.Color

The color you want to use

setFont(self, font: str) None

Set the font of the characters. The display should be initialized before.

To know which font are available, on Unix you can use xfontsel or xlsfonts utilities.

setGraphThickness(self, graphNum: int, thickness: int) None

This function enables you to choose the thickness used to draw all the curves belonging to a given graphic.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

thickness: int

The thickness you want to use

setGridThickness(self, graphNum: int, thickness: int) None

This function enables you to choose the thickness used to draw the grid and the axis of a given graphic.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

thickness: int

The thickness you want to use

setLegend(self, graphNum: int, curveNum: int, legend: str) None

Sets the legend of a curve.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

curveNum: int

The index of the curve in the list of the curves belonging to the graphic.

legend: str

The legend of the curve.

setThickness(self, graphNum: int, curveNum: int, thickness: int) None

This function enables you to choose the thickness used to draw a given curve.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

curveNum: int

The index of the curve in the list of the curves belonging to the graphic.

thickness: int

The thickness you want to use

setTitle(self, graphNum: int, title: str) None

Sets the title of a graphic.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

title: str

The graphic title.

setUnitX(self, graphNum: int, unitx: str) None

Sets the unit system of the x axis.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

unitx: str

The name of the unit of the x axis.

setUnitY(self, graphNum: int, unity: str) None

Sets the unit system of the y axis.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

unity: str

The name of the unit of the y axis.

setUnitZ(self, graphNum: int, unitz: str) None

Sets the unit system of the z axis.

Parameters:
graphNum: int

The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

unitz: str

The name of the unit of the z axis.