import plotly.graph_objects as go # convert date column to datetime data['time'] = pd.to_datetime(data['time']) # format date column to quarterly periods data['date_quarterly'] = data['time'].dt.to_period('Q').astype(str) periods = data['date_quarterly'].tolist() # calculate topic activity over time act = model.topic_activity_over_time(periods) # visualize topic activity fig = model.visualize_topic_activity(top_n=8, topic_activity=act, time_slices=periods) # 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()