iota.graph
Description
This module provides functionalities to generate, edit, display and export graphs.
Generating graphs
Accessing, adding and deleting data from the graph
Displaying and exporting graphs
Getting and setting graph layout
Generate a graph with a scatter plot of trace given its x and y values
Parameters
x
: (list of floats or numpy.ndarray of floats) x-values of the tracey
: (list of floats or numpy.ndarray of floats) y-values of the tracename
: (str) name for the tracetitle
: (str) title of the graph (default: None)x_label
: (str) title for the x-axis (Default: None)y_label
: (str) title for the y-axis (Default: None)layout
: (plotly.go_objs.Layout) a plotly layout object with the settings for the layout of the graph (Default: None)
Output
A Graph object that contains a collection of data represented as a trace
Example
Generating graph with a scatter 2D plot called 'Maximum Pressure' and given the array of x values and the array of y values
Generate a graph with a scatter plot of trace given its x and y values
Parameters
name
: (str) name for the histogramvalues
: (list of floats or numpy.ndarray of floats) list of values to build the histogramnbins
: (int) maximum number of bins for the histogram (ignored ifsizebins
is provided)sizebins
: (float) size for the bins of the histogramnormalize
: (str) method to normalize the values of the height of the bins (Default: '')''
: number of occurrences'percent'
: percentage of occurrences with respect to the total number of values invalue
(sum of the height of all bins is equal to 100%)'probability'
: fraction of occurrences with respect to the total number of values invalue
(sum of the height of all bins is equal to 1)'density'
: number of occurrences in a bin is divided by the of the bin (sum of all bin areas is equal to total number of values invalue
)'probability density'
: the area of each bin corresponds to the probability that an event falls within the corresponding bin (sum of all bin areas is equal to 1)
title
: (str) title for graph (Default: None)x_label
: (str) title for the x-axis (Default: None)y_label
: (str) title for the y-axis (Default: None)layout
: (plotly.go_objs.Layout) a plotly layout object with the settings for the layout of the graph (Default: None)
Output
A Graph object that contains a collection of data represented as a histogram
Examples
Generating a new graph with a histogram called 'Pressure' given an array with the values and a maximum number of bins equal to 4
Generating a new graph with a histogram called 'Pressure' given an array with the values, a bin size equal to 0.5 and normalizing the height of the bin based on percentage
Graph class object. This object is returned when generating a plot using one of the plot methods in the iota.graph (see for example iota.graph.plot_xy or iota.graph.plot_histogram)
Methods
Add a plotly.go_objs.Data object to the graph. The Data objects contains a list of data collections objects.
Parameters
name
: name of the datadata
: (plotly.go_objs.Data) Data object containing a list of data collections
Example
Adding a Data object that contains a list of two traces
Add a new data collection as a histogram to the graph
Parameters
name
: (str) name for the histogramvalues
: (list of floats or numpy.ndarray of floats) list of values to build the histogramnbins
: (int) maximum number of bins for the histogram (ignored ifsizebins
is provided)sizebins
: (float) size for the bins of the histogramnormalize
: (str) method to normalize the values of the height of the bins (Default: '')''
: number of occurrences'percent'
: percentage of occurrences with respect to the total number of values invalue
(sum of the height of all bins is equal to 100%)'probability'
: fraction of occurrences with respect to the total number of values invalue
(sum of the height of all bins is equal to 1)'density'
: number of occurrences in a bin is divided by the of the bin (sum of all bin areas is equal to total number of values invalue
)'probability density'
: the area of each bin corresponds to the probability that an event falls within the corresponding bin (sum of all bin areas is equal to 1)
Examples
Adding a new histogram called 'histogram 1' with maximum number of bins equal to 4
Adding a new histogram called 'histogram 1' with bin size equal to 0.5 and normalizing the height of the bin based on percentage
Add a new data collection as a trace (scatter) to the graph
Parameters
name
: (str) name of the tracex
: (list of floats or numpy.ndarray of floats) x-values of the tracey
: (list of floats or numpy.ndarray of floats) y-values of the trace
Examples
Adding a new trace to an existing graph given the x and y values as a list of floats
Adding a new trace to an existing graph given the x and y values as numpy array of floats
Display the graph in the working notebook
Parameters
width
: (int) width for the display of the graph in pixels (Default: 800)height
: (int) height for the display of the graph in pixels (Default: 600)
Examples
Displaying the graph with the default height and width
Displaying the graph and setting its width to 1000 pixels and height to 800 pixels
Delete an existing collection of data (e.g. a trace data or a histogram data) from the graph given the name of the data collection
Parameters
name
: (str) name of the collection of data to be deleted from the graph
Example
Deleting the existing trace called 'my new trace' from the graph
Export the data values of the traces and histograms in the graph to csv file
Parameters
file
: (str) path for the csv file
Example
Exporting the data values of a graph to a csv file called 'my_graph_data.csv'
Export the graph to html file
Parameters
s
file
: (str) path for the csv fileauto_open
: (bool) If True, the exported html file is automatically opened in your web browser (Default: False)width
: (int) width for th graph in pixels (Default: 800)height
: (int) height for the graph in pixels (Default: 600)
Examples
Exporting a graph to a html file called 'my_graph.html'
Exporting the graph to a html file call 'my_graph.html' and setting its width to 1000 pixels and height to 800 pixels
Get the plotly graph object that represents a data collection in the graph
Parameters
name
: (str) name of the data collection
Output
A plotly graph object representing the data collection:
Example
Getting the plolty graph object of the existing trace called 'Trace 1' in the graph
Set the a new plotly graph object to an existing data collection in the graph
Parameters
name
: (str) name of the existing data collectiondata
: (plotly.graph_objs) a plotly graph object with the new setting for the data collection:
Examples
Creating a new graph with a trace called 'Trace 1' ands setting afterwards the x-values of the trace to a new list of values
Get a layout object that contains the settings of the layout of the graph
Output
A plotly layout object that contains the settings of the layout
Example
Getting the layout settings of a graph
Set the settings of the layout of graph
Parameters
title
: (str) title for the graph (Default: None)x_label
: (str) title for the x-axis (Default: None)y_label
: (str) title for the y-axis (Default: None)x_range
: (list of two floats): Min and Max values defining the range of the x-axis (Default: None)y_range
: (list of two floats): Min and Max values defining the range of the y-axis (Default: None)width
: (int) width of the graph in pixels (Default: None)height
: (int) width of the graph in pixels (Default: None)
Example
Setting the title of the graph, x-axis and y-axis
Setting the range of the x-axis and y-axis to [0, 100] and [50, 600] respectively
Last updated
Was this helpful?