poliastro.plotting.orbit.backends.plotly

A module implementing orbit plotter backends based on Plotly.

Module Contents

Classes

BasePlotly

An orbit plotter backend class based on Plotly.

Plotly2D

An orbit plotter backend class based on Plotly.

Plotly3D

An orbit plotter backend class based on Plotly.

class poliastro.plotting.orbit.backends.plotly.BasePlotly(figure, layout)

Bases: poliastro.plotting.orbit.backends._base.OrbitPlotterBackend

An orbit plotter backend class based on Plotly.

property figure

The plotly figure use to render the scene.

Returns

The plotly Figure representing the scene.

Return type

Figure

property layout

The plotly layout of the figure.

Returns

The plotly Layout object linked to the figure.

Return type

Layout

property scene

Return the scene object.

property name

Return the name of the backend.

Returns

Name of the backend.

Return type

str

property is_2D

Assert if backend is 2D.

Returns

True if it is a 2D backend, False if it is not.

Return type

bool

property is_3D

Assert if backend is 3D.

Returns

True if it is a 3D backend, False if it is not.

Return type

bool

update_layout(layout)

Update the layout of the figure scene.

Parameters

layout (Layout) – The new plotly Layout to be used in the figure.

undraw_attractor()

Removes the attractor from the scene.

draw_position(position, *, color, label, size)

Draw the position of a body in the scene.

Parameters
  • position (list[float, float, float]) – A list containing the x, y and z coordinates of the point.

  • color (str) – A string representing the hexadecimal color for the marker.

  • label (str) – The name shown in the figure legend to identify the position.

  • size (float) – The size of the marker.

Returns

An object representing the trace of the coordinates in the scene.

Return type

[Surface, Trace]

draw_impulse(position, *, color, label, size)

Draw an impulse into the scene.

Parameters
  • position (list[float, float]) – A list containing the x and y coordinates of the impulse location.

  • color (str) – A string representing the hexadecimal color for the impulse marker.

  • label (str) – The name shown in the figure legend to identify the impulse.

  • size (float) – The size of the marker for the impulse.

Returns

An object representing the trace of the impulse in the scene.

Return type

object

update_legend()

Update the legend of the scene.

resize_limits()

Resize the limits of the scene.

show()

Display the scene.

generate_labels(label, has_coordinates, has_position)

Generate the labels for coordinates and position.

Parameters
  • label (str) – A string representing the label.

  • has_coordinates (boolean) – Whether the object has coordinates to plot or not.

  • has_position (boolean) – Whether the object has a position to plot or not.

Returns

A tuple containing the coordinates and position labels.

Return type

tuple

abstract draw_marker(position, *, color, label, marker_symbol, size)

Draw desired marker into the scene.

Parameters
  • position (list[float, float, float]) – A list containing the x, y and z coordinates of the point.

  • color (str) – A string representing the hexadecimal color for the point.

  • label (str) – The name to be used in the legend for the marker.

  • marker_symbol (str) – The marker symbol to be used when drawing the point.

  • size (float) – The size of the marker.

abstract draw_sphere(position, *, color, label, radius)

Draw an sphere into the scene.

Parameters
  • position (list[float, float, float]) – A list containing the x, y and z coordinates of the sphere location.

  • color (str) – A string representing the hexadecimal color for the sphere.

  • label (str) – The name to be used in the legend for the marker.

  • radius (float) – The radius of the sphere.

abstract draw_coordinates(coordinates, *, colors, label, size)

Draw desired coordinates into the scene.

Parameters
  • position (list[list[float, float, float], ...]) – A set of lists containing the x, y and z coordinates of the sphere location.

  • colors (list[str]) – A string representing the hexadecimal color for the coordinates.

  • label (str) – The name to be used in the legend for the marker.

  • size (float) – The size of the marker for drawing the coordinates.

abstract draw_axes_labels_with_length_scale_units(length_scale_units)

Draw the desired label into the specified axis.

Parameters

lenght_scale_units (Unit) – Desired units of lenght used for representing distances.

class poliastro.plotting.orbit.backends.plotly.Plotly2D(figure=None, use_dark_theme=False)

Bases: BasePlotly

An orbit plotter backend class based on Plotly.

property figure

The plotly figure use to render the scene.

Returns

The plotly Figure representing the scene.

Return type

Figure

property layout

The plotly layout of the figure.

Returns

The plotly Layout object linked to the figure.

Return type

Layout

property scene

Return the scene object.

property name

Return the name of the backend.

Returns

Name of the backend.

Return type

str

property is_2D

Assert if backend is 2D.

Returns

True if it is a 2D backend, False if it is not.

Return type

bool

property is_3D

Assert if backend is 3D.

Returns

True if it is a 3D backend, False if it is not.

Return type

bool

draw_marker(position, *, color, label, marker_symbol, size)

Draw a marker into the scene.

Parameters
  • position (list[float, float]) – A list containing the x and y coordinates of the point.

  • color (str) – A string representing the hexadecimal color for the point.

  • label (str) – The name shown in the legend of the figure to identify the marker.

  • marker_symbol (str) – The marker symbol to be used when drawing the point.

  • size (float) – Desired size for the marker.

Returns

An object representing the trace of the marker in the scene.

Return type

object

draw_sphere(position, *, color, label, radius)

Draw an sphere into the scene.

Parameters
  • position (list[float, float]) – A list containing the x and y coordinates of the sphere location.

  • color (str) – A string representing the hexadecimal color for the sphere.

  • label (str) – Unuseful for this routine. See the Notes section.

  • radius (float) – The radius of the sphere.

Notes

Plotting a sphere in a two-dimensional figure in plotly requires a shape instead of a trace. Shapes do not accept a label, as the legend does not support labels for shapes.

Returns

A dictionary representing the shape of the sphere.

Return type

dict

draw_coordinates(coordinates, *, colors, dashed, label)

Draw desired coordinates into the scene.

Parameters
  • position (list[list[float, float, float]]) – A set of lists containing the x and y coordinates of the sphere location.

  • colors (list[str]) – A list of string representing the hexadecimal color for the coordinates.

  • dashed (bool) – Whether to use a dashed or solid line style for the coordiantes.

  • label (str) – The name shown in the legend for identifying the coordinates.

Returns

trace_coordinates – An object representing the trace of the coordinates in the scene.

Return type

object

draw_axes_labels_with_length_scale_units(length_scale_units)

Draw the desired label into the specified axis.

Parameters

lenght_scale_units (Unit) – Desired units of lenght used for representing distances.

update_layout(layout)

Update the layout of the figure scene.

Parameters

layout (Layout) – The new plotly Layout to be used in the figure.

undraw_attractor()

Removes the attractor from the scene.

draw_position(position, *, color, label, size)

Draw the position of a body in the scene.

Parameters
  • position (list[float, float, float]) – A list containing the x, y and z coordinates of the point.

  • color (str) – A string representing the hexadecimal color for the marker.

  • label (str) – The name shown in the figure legend to identify the position.

  • size (float) – The size of the marker.

Returns

An object representing the trace of the coordinates in the scene.

Return type

[Surface, Trace]

draw_impulse(position, *, color, label, size)

Draw an impulse into the scene.

Parameters
  • position (list[float, float]) – A list containing the x and y coordinates of the impulse location.

  • color (str) – A string representing the hexadecimal color for the impulse marker.

  • label (str) – The name shown in the figure legend to identify the impulse.

  • size (float) – The size of the marker for the impulse.

Returns

An object representing the trace of the impulse in the scene.

Return type

object

update_legend()

Update the legend of the scene.

resize_limits()

Resize the limits of the scene.

show()

Display the scene.

generate_labels(label, has_coordinates, has_position)

Generate the labels for coordinates and position.

Parameters
  • label (str) – A string representing the label.

  • has_coordinates (boolean) – Whether the object has coordinates to plot or not.

  • has_position (boolean) – Whether the object has a position to plot or not.

Returns

A tuple containing the coordinates and position labels.

Return type

tuple

class poliastro.plotting.orbit.backends.plotly.Plotly3D(figure=None, use_dark_theme=False)

Bases: BasePlotly

An orbit plotter backend class based on Plotly.

property figure

The plotly figure use to render the scene.

Returns

The plotly Figure representing the scene.

Return type

Figure

property layout

The plotly layout of the figure.

Returns

The plotly Layout object linked to the figure.

Return type

Layout

property scene

Return the scene object.

property name

Return the name of the backend.

Returns

Name of the backend.

Return type

str

property is_2D

Assert if backend is 2D.

Returns

True if it is a 2D backend, False if it is not.

Return type

bool

property is_3D

Assert if backend is 3D.

Returns

True if it is a 3D backend, False if it is not.

Return type

bool

draw_marker(position, *, color, marker_symbol, label, size)

Draw a marker into the scene.

Parameters
  • position (list[float, float]) – A list containing the x and y coordinates of the point.

  • color (str) – A string representing the hexadecimal color for the point.

  • marker_symbol (str) – The marker symbol to be used when drawing the point.

  • label (str) – The name shown in the legend of the figure to identify the marker.

  • size (float) – Desired size for the marker.

Returns

An object representing the trace of the marker in the scene.

Return type

object

draw_sphere(position, *, color, label, radius)

Draw an sphere into the scene.

Parameters
  • position (list[float, float]) – A list containing the x and y coordinates of the sphere location.

  • color (str) – A string representing the hexadecimal color for the sphere.

  • label (str) – The name shown in the legend of the figure to identify the sphere.

  • radius (float) – The radius of the sphere.

Returns

An object representing the trace of the sphere in the scene.

Return type

object

draw_coordinates(coordinates, *, colors, dashed, label)

Draw desired coordinates into the scene.

Parameters
  • position (list[list[float, float, float]]) – A set of lists containing the x and y coordinates of the sphere location.

  • colors (list[str]) – A list of string representing the hexadecimal color for the coordinates.

  • dashed (bool) – Whether to use a dashed or solid line style for the coordiantes.

  • label (str) – The name shown in the legend of the figure to identify the coordinates.

Returns

trace_coordinates – An object representing the trace of the coordinates in the scene.

Return type

object

draw_axes_labels_with_length_scale_units(length_scale_units)

Draw the desired label into the specified axis.

Parameters

lenght_scale_units (Unit) – Desired units of lenght used for representing distances.

set_view(elevation_angle, azimuth_angle, distance)

Change 3D view.

Parameters
  • elevation_angle (float) – Desired elevation angle in radians.

  • azimuth_angle (float) – Desired azimuth angle in radians.

  • distance (float) – Desired distance of the camera.

update_layout(layout)

Update the layout of the figure scene.

Parameters

layout (Layout) – The new plotly Layout to be used in the figure.

undraw_attractor()

Removes the attractor from the scene.

draw_position(position, *, color, label, size)

Draw the position of a body in the scene.

Parameters
  • position (list[float, float, float]) – A list containing the x, y and z coordinates of the point.

  • color (str) – A string representing the hexadecimal color for the marker.

  • label (str) – The name shown in the figure legend to identify the position.

  • size (float) – The size of the marker.

Returns

An object representing the trace of the coordinates in the scene.

Return type

[Surface, Trace]

draw_impulse(position, *, color, label, size)

Draw an impulse into the scene.

Parameters
  • position (list[float, float]) – A list containing the x and y coordinates of the impulse location.

  • color (str) – A string representing the hexadecimal color for the impulse marker.

  • label (str) – The name shown in the figure legend to identify the impulse.

  • size (float) – The size of the marker for the impulse.

Returns

An object representing the trace of the impulse in the scene.

Return type

object

update_legend()

Update the legend of the scene.

resize_limits()

Resize the limits of the scene.

show()

Display the scene.

generate_labels(label, has_coordinates, has_position)

Generate the labels for coordinates and position.

Parameters
  • label (str) – A string representing the label.

  • has_coordinates (boolean) – Whether the object has coordinates to plot or not.

  • has_position (boolean) – Whether the object has a position to plot or not.

Returns

A tuple containing the coordinates and position labels.

Return type

tuple