df = pd.read_json(os.path.join(path_rq12, 'macro-topics.json'))
categories = []
frequency_p = []
frequency_k = []
for index, group in df.groupby('Challenge_topic_macro'):
categories.append(macro_topic_indexing[index])
frequency_p.append(len(group[group['Challenge_type'] == 'problem']))
frequency_k.append(len(group[group['Challenge_type'] == 'knowledge']))
# Create a stacked bar chart
fig = go.Figure(data=[
go.Bar(name='Problem', x=categories, y=frequency_p, text=frequency_p, textposition='outside'),
go.Bar(name='Knowledge', x=categories, y=frequency_k, text=frequency_k, textposition='outside')
])
# Change the bar mode
fig.update_layout(
barmode='group',
xaxis_title="Macro-topic Name",
yaxis_title="Post Number",
xaxis=dict(title_font=dict(size=18)),
yaxis=dict(title_font=dict(size=18)),
)
fig.show()
fig.write_image(os.path.join(path_rq12, 'Macro-topics frequency histogram.pdf'))
I am working with plotly but the output image show the watermark:
My code:
My output image:

OS: Ubuntu 20.04
Python: 3.10.9
Plotly: 5.16.1