truelearn.utils.visualisations.BubblePlotter#

class truelearn.utils.visualisations.BubblePlotter(title: str = "Comparison of learner's subjects")[source]#

Bases: MatplotlibBasePlotter

Bubble plotter.

In the bubble chart, each knowledge component is represented by a bubble of a certain size and shade.

The size of the bubble is proportional to the mean of the knowledge component.

The shade of the bubble represents the variance of the knowledge component. The lighter the shade, the greater the variance.

Methods

__init__([title])

Init a bubble 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 figure if the caller is in an interactive environment.

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 = "Comparison of learner's subjects")[source]#

Init a bubble plotter.

Parameters:

title – The default title of the visualization

plot(content: Knowledge, topics: Optional[Iterable[str]] = None, top_n: Optional[int] = None) 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.

Currently, this method requires that the mean of all the knowledge components of the learner Knowledge to be positive.

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).

  • 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.

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”.

    You can use print(plotter.fig.canvas.get_supported_filetypes()) to find out the supported file formats in your platform.

    You can optionally pass in these arguments:
    dpi:

    The dpi of the image.

Notes

You can refer to matplotlib’s documentation for savefig to find out more supported arguments.

show()[source]#

Display the figure if the caller is in an interactive environment.

For example, if you use Jupyter Notebooks, it will be displayed.

If you want to display the visualisations in a non-interactive environment, you can use plt.show() instead.

title(text: str)[source]#

Set the title of the figure.

Parameters:

text – The title of the figure.

xlabel(text: str)[source]#

Set the x label of the figure.

Parameters:

text – The x label of the figure.

ylabel(text: str)[source]#

Set the y label of the figure.

Parameters:

text – The y label of the figure.