Open Tmpts21 opened 1 month ago
Hello @Tmpts21! I'm here to help you with any bugs, questions, or contributions you have. Let's work together to resolve this issue!
To display Japanese characters correctly in your plot, you can set the font to one that supports Japanese characters, such as 'SimHei' or another appropriate font. You can configure matplotlib
to use this font before generating the plot. Here is an example of how you can modify your code to include this configuration:
import matplotlib.pyplot as plt
# Set the font for matplotlib
plt.rcParams['font.sans-serif'] = ['SimHei'] # Use a font that supports Japanese characters
plt.rcParams['axes.unicode_minus'] = False # Ensure the minus sign is displayed correctly
df = dfs[0]
description = df.describe()
top_attackers = df.nlargest(5, 'Attack')
plt.figure(figsize=(10, 6))
plt.barh(top_attackers['Name'], top_attackers['Attack'])
plt.xlabel('名前')
plt.ylabel('攻撃')
plt.title('Top 5 Pokémon by Attack')
plt.savefig('C:/Users/P102NRPH1/Desktop/generative-ai/demo-data-analysis/exports/charts/temp_chart.png')
result = {'type': 'plot', 'value': 'C:/Users/P102NRPH1/Desktop/generative-ai/demo-data-analysis/exports/charts/temp_chart.png'}
Additionally, ensure you are using the recommended version of matplotlib
for compatibility with pandas-ai
:
matplotlib = "^3.7.1"
This should help in rendering the Japanese characters correctly in your plot [1][2].
To continue the conversation, mention @dosu.
System Info
pandas 2.2.0 , python 3.11
🐛 Describe the bug
I am trying to display japanese characters in the generated plot results but it doesn't display the characters correctly.
Here is my sample query :
plot the top 5 pokemon based on attack. change the label for Y axis to "攻撃" and "名前" for X axis.
plot result :![image](https://github.com/Sinaptik-AI/pandas-ai/assets/60459436/fe6174d8-dc22-4f18-8dee-4fd0b7c3da8f)
Here is the last_executed_code method result :
df = dfs[0] description = df.describe() top_attackers = df.nlargest(5, 'Attack') plt.figure(figsize=(10, 6)) plt.barh(top_attackers['Name'], top_attackers['Attack']) plt.xlabel('名前') plt.ylabel('攻撃') plt.title('Top 5 Pokémon by Attack') plt.savefig('C:/Users/P102NRPH1/Desktop/generative-ai/demo-data-analysis/exports/charts/temp_chart.png') result = {'type': 'plot', 'value': 'C:/Users/P102NRPH1/Desktop/generative-ai/demo-data-analysis/exports/charts/temp_chart.png'}
Here is how I create the smartdataframe instance :
df = SmartDataframe(st.session_state.context, config={"llm": llm })
How can I resolve this? Is there a configuration I can add so that pandas ai can display these type of characters? Thanks for the help !!