# topic activity over time import plotly.graph_objects as go # create timestamps data['time'] = pd.to_datetime(data['time']) timestamps = data['time'].to_list() # generate topics over time, 20 bins correspond to Q frequency topics_over_time = model.topics_over_time(docs, timestamps, nr_bins=20) # filter out topic -1 containing outliers topics_over_time_filtered = topics_over_time[topics_over_time['Topic'] != -1] # visualize the filtered topics over time fig = model.visualize_topics_over_time(topics_over_time_filtered) # update legend to display only the topic number fig.data = sorted(fig.data, key=lambda trace: trace.name) for trace in fig.data: trace.name = trace.name[0] # update the layout fig.update_layout( width=1200, height=600, title='', legend_title_text='Topic', xaxis_tickangle=45 # set x-axis labels to 45-degree angle ) # show the figure fig.show()