truelearn.utils.visualisations
.LinePlotter#
- class truelearn.utils.visualisations.LinePlotter(title: str = '', xlabel: str = 'Time', ylabel: str = 'Mean')[source]#
Bases:
PlotlyBasePlotter
Line plotter.
Line plotter provides 2 kinds of visualization:
Mean of multiple knowledge components for one learner vs. time
Mean of a topic from multiple learners vs. time
In each mode, the x-axis represents the time and the y-axis represents the mean of the topic.
Because history must be used in this plotter, you need to use the knowledge components that support history.
Methods
__init__
([title, xlabel, ylabel])Init a line plotter.
plot
(content[, topics, top_n, ...])Plot the graph based on the given data.
savefig
(file, **kargs)Export the visualisation to a file.
show
()Display the visualisation in a new webpage.
title
(text)Set the title of the figure.
xlabel
(text)Set the x label of the figure.
ylabel
(text)Set the y label of the figure.
- __init__(title: str = '', xlabel: str = 'Time', ylabel: str = 'Mean')[source]#
Init a line plotter.
- Parameters:
title – The default title of the visualization
xlabel – The default x label of the visualization
ylabel – The default y label of the visualization
- plot(content: Union[List[Knowledge], Knowledge], topics: Optional[Iterable[str]] = None, top_n: Optional[int] = None, visualise_variance: bool = False) Self [source]#
Plot the graph based on the given data.
It will not draw anything if the knowledge given by the user is empty, or if topics and top_n make the filtered knowledge empty.
- Parameters:
content – The Knowledge object to use to plot the visualisation.
topics – The list of topics in the learner’s knowledge to visualise. If None, all topics are visualised (unless top_n is specified, see below). Only applicable if the content is of type Knowledge
top_n – The number of topics to visualise. E.g. if top_n is 5, then the top 5 topics ranked by mean will be visualised.
visualise_variance – Whether to visualise variance.
- savefig(file: str, **kargs)[source]#
Export the visualisation to a file.
- Parameters:
file – The local file path in which to create the file.
**kargs –
Optional supported arguments as shown below.
This method supports saving the visualisation in various formats. Most platforms support the following formats: “png”, “jpg” or “jpeg”, “svg”, “pdf”, “html”, “json”.
- If you want to export a HTML file, you can optionally pass in
- default_width:
The default width of the image in the HTML file.
- default_height:
The default height of the image in the HTML file.
- encoding:
The encoding of the saved HTML file. If unspecified, the encoding will be utf-8.
- If you want to export a JSON file, you can optionally pass in
- pretty:
Whether the saved JSON representation should be pretty-printed.
- encoding:
The encoding of the saved JSON file. If unspecified, the encoding will be utf-8.
- If you want to export an image file, you can optionally pass in
- width:
The default width of the image.
- height:
The default height of the image.
Notes
You can refer to Plotly’s documentation for write_image and write_html to find out more supported arguments.
- show()[source]#
Display the visualisation in a new webpage.
Equivalent to calling Plotly’s Figure.show() method.