1.6. py_pol.drawings module

functions for drawing

py_pol.drawings.draw_ellipse(E, N_angles=91, filename='', figsize=(6, 6), limit='', draw_arrow=True, draw_labels=True, draw_titles=True, depol_central=False, depol_contour=False, depol_prob=False, subplots=None, N_prob=256, contour_levels=0.9, cmap='hot', *args, **kwargs)[source]

Draws polarization ellipse of Jones vector.

Parameters:
  • E (Jones_vector or Stokes) – Light object.

  • N_angles (int) – Number of angles to plot the ellipses. Default: 91.

  • filename (str) – name of filename to save the figure.

  • figsize (tuple) – A tuple of length 2 containing the figure size. Default: (8,8).

  • limit (float) – limit for drawing. If empty, it is obtained from amplitudes.

  • draw_arrow (bool) – If True, draws an arrow containing the turning sense of the polarization. Does not work with linear polarization vectors. Default: True.

  • draw_labels (bool) – It True, draws axis labels and tick labels. Default: True.

  • draw_titles (bool) – If True, draws axis titles. Default: True.

  • depol_central (bool) – If True, draws a central circle containing the unpolarized field amplitude. Default: False.

  • depol_contour (bool) – If True, draws a line enveloping the polarization ellipse in order to plot the depolarization. Default: False.

  • depol_prob (bool) – If True, plots the probability distribution of the electric field. Default: False.

  • subplots (string, tuple or None) – If AS_SHAPE, divides the figure in several subplots as the shape of the py_pol object. If INDIVIDUAL, each vector is represented in its own subaxis, trying to use a square grid. If tuple, divides the figure in that same number of subplots. If None, all ellipses are plot in the same axes. Default: None.

  • N_prob (int) – Number of points in each dimension for probability distributions. Default: 256.

  • contour_levels (float, np.ndarray, tuple or list) – Contains the contour levels (normalized to 1). Default: 0.9.

  • cmap (str or color object) – Default colormap for probability distributions. Default: hot.

Returns:

handle to figure. ax (list of handles): handles to axes.

Return type:

fig (handle)

py_pol.drawings.draw_poincare(S, fig=None, figsize=(6, 6), draw_axes=True, draw_guides=True, kind='scatter', depol=False, param=None, subplots=False, in_degrees=False, log=False, color_limits=(None, None), hover='components', colormap='Blackbody', show_fig=False)[source]

Function to draw the Jones or Stokes vectors in the Poincare sphere using plotly.

Parameters:
  • S (Jones_vector or Stokes) – Object to be represented.

  • fig (plotly.graph_objects.Figure) – Figure to plot the data. Default: None

  • figsize (2-element iterable) – Figure size. Default: (6,6)

  • draw_axes (bool) – If True, it draws the three axes of the Poincare space. Default: True

  • draw_guides (bool) – If True, it draws the circles of S1, S2 and S3 = 0. Default: True

  • kind (str) – Choose between ‘scatter’, ‘line’, ‘scatterline’ or ‘surf’ to represent the data. If surf, the object must be 2D, 3D or 4D. Else, it must be 0D, 1D, 2D or 3D. Default: ‘scatter’.

  • depol (bool) – If True, the depolarization is taking into account for scatter and line plots shrinking the radius below 1. Default: False.

  • param (str, np.ndarray or None) – If str, parameter to use as information for the color. Must be a method of Parameters class which returns a single variable. If np.ndarray, must have the same shape as S. Default: None.

  • subplots (bool) – If True, it tries to use the first two dimensions as rows and columns. If method == ‘surf’, this is mandatory. Default: False.

  • in_degrees (bool) – If True, transforms the parameters to degrees. Default: False.

  • log (bool) – If True, it calculates it in logarithmic scale. Default: False.

  • color_limits (float, float) – limits in color

  • hover (str) – Choose between ‘components’ (S1, S2, S3) or ‘angles’ (azimuth, ellipticity). Default: ‘components’.

  • colormap (str) – Colormap of the plots. Default: ‘Blackbody’.

  • show_fig (bool) – If True, the figure is inmediately plotted. Default: False.

Returns:

Plotly figure.

Return type:

fig (go.Figure)