MuonDataLib API documentation: Figure
plot.basic.Figure
An object to handle making Plotly plots.
- Optional Parameters:
title: The title for the plot. Default value: ‘’.
x_label: The label for the x axis. Default value: time (micro seconds).
y_label: The label for the y axis. Default value: Counts.
Example:
from MuonDataLib.plot.basic import Figure
fig = Figure("Example plot", y_label="Temp (Kelvin)")
plot.basic.Figure.plot
A method to create a simple plot in the Figure object.
- Required Parameters:
bin_centres: The list of bin centres (i.e. point data).
y_values: The y values to plot.
label: The label to give the data set in the legend
Example:
from MuonDataLib.plot.basic import Figure
import numpy as np
fig = Figure("Example plot")
x = np.arange(0, 10)
y = np.sin(2.1*x)
fig.plot(x, y, "sin(2.1 x)")
plot.basic.Figure.show
A method to generate and present the plot from the Figure object.
Example:
from MuonDataLib.plot.basic import Figure
import numpy as np
fig = Figure("Example plot")
x = np.arange(0, 10)
y = np.sin(2.1*x)
fig.plot(x, y, "sin(2.1 x)")
fig.show()
plot.basic.Figure.plot_peak_property_histogram
A method to create a plot of histogram data from a peak property.
- Required Parameters:
hist: The histogram matrix (as from np.histogram)
bins: The bin edges for the histogram.
- Optional Parameters:
label: The base label to use in the legend. Default value: “”.
Example:
from MuonDataLib.plot.basic import Figure
from MuonDataLib.data.loader.load_events import load_events
data = load_events("HIFI00001.nxs", 64)
hist, bins = data.get_peak_property_histogram("Amplitudes")
fig = Figure("Example plot")
fig.plot_peak_property_histogram(hist, binslabel="HIFI00001")
fig.show()
plot.basic.Figure.plot_from_histogram
A method to store that data needed to make a plot of histogram data.
- Required Parameters:
bins: The bin edges for the histogram.
hist: The histogram matrix (period, spectrum number, bins).
det_list: The list of spectrum numbers to plot.
- Optional Parameters:
label: The base label to use in the legend. Default value: “”.
period: The period to plot. Default value: 1.
Example:
from MuonDataLib.plot.basic import Figure
from MuonDataLib.data.loader.load_events import load_events
data = load_events("HIFI00001.nxs", 64)
hist, bins = data.histogram()
fig = Figure("Example plot")
fig.plot_from_histogram(bins, hist, [1, 3, 5], label="HIFI00001")
fig.show()
plot.basic.Figure.plot_sample_log
A method to add the data to plot the current (filtered) sample logs and their original values.
- Required Parameters:
muon_data: The MuonData object that contains the log that we want to plot.
log_name: The name of the sample log to plot
Example:
from MuonDataLib.plot.basic import Figure
from MuonDataLib.data.loader.load_events import load_events
data = load_events("HIFI00001.nxs", 64)
fig = Figure("Example plot")
fig.plot_sample_log(data, "HIFI_field")
fig.show()