physics_utils.graph module¶
- class physics_utils.graph.SimpleGraph(title)¶
Bases:
objectCreates a plot with automatic error bars
- best_fit(return_as_md=False)¶
Creates a linear line of best fit on the graph, for the last set x- and y-axes
- Returns:
Returns a tuple containing two tuples, with both tuples containing two values - the first value being a measurement, and the second an uncertainty. The first tuple represents the slope; and the second, the y-intercept.
- Return type:
tuple
- plot_points()¶
Plots the currently set x- and y-axes on the graph, with error bars
- Return type:
None
- put_labels()¶
Adds axes labels to the graph, using the labels given on the last sets of x- and y-axes datas
- Return type:
None
- put_legend()¶
Adds a legend to the graph
- Return type:
None
- set_x_axis(values, label)¶
Sets the x-axis values and error
- Parameters:
values (list[MeasuredData]) – The data points for the x-axis
label (str) – The label for these data points
- Return type:
None
Examples
>>> graph = SimpleGraph("New Graph") >>> graph.set_x_axis([MeasuredData(0, 1), MeasuredData(1, 1), MeasuredData(2, 1)], "X-Axis") >>> graph.x_data [0.0, 1.0, 2.0] >>> graph.x_error [1, 1, 1] >>> graph.x_label == "X-Axis" True
- set_y_axis(values, label)¶
Sets the y-axis values and error
- Parameters:
values (list[MeasuredData]) – The data points for the y-axis
label (str) – The label for these data points
- Return type:
None
- physics_utils.graph.show()¶
Displays all created graphs