Preview:
import mysql.connector
import pandas as pd
import matplotlib.pyplot as plt
mydb = mysql.connector.connect(
    host="localhost",
    user="root",
    password="Eimaipolykala1",
    database="twitter_db"
)

cursor = mydb.cursor()

# Execute SQL query to retrieve data
cursor.execute("SELECT JSON_VALUE(data, '$.lang') AS lang, COUNT(*) AS count FROM data_db GROUP BY JSON_VALUE(data, '$.lang')")

# Fetch data
data = cursor.fetchall()

# Close the connection
mydb.close()
languages = [row[0] for row in data]
counts = [row[1] for row in data]
df = pd.DataFrame(data, columns=['language', 'count'])
df = df.dropna()
plt.figure(figsize=(10, 6))
plt.bar(df['language'], df['count'])
plt.xlabel('Languages')
plt.ylabel('Number of Tweets')
plt.title('Number of Tweets by Language')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter