Esempio n. 1
0
    def words_in_topic(self, i_topic: int, axis: Subplot) -> AxesImage:
        """Plot the relative importance of words in a given topic.

        Parameters
        ----------
        i_topic: int
            Index of the topic to plot. Numbering starts at 0.
        axis: Subplot
            The matplotlib axis to plot into.

        Returns
        -------
        AxesImage
            The image with the produced word cloud.

        """
        word_given_topic = dict(self.__word_given_topic[i_topic])
        wordcloud = self.__wordcloud.generate_from_frequencies(word_given_topic)
        axis.set_title(f'Topic {i_topic}')
        axis.set_axis_off()
        return axis.imshow(wordcloud, interpolation='bilinear')