matplotlib in java

import matplotlib.pyplot as plt
import pandas as pd

data = {
    'Name': ['A', 'B', 'C', 'D'],
    'Score1': [85, 90, 78, 92],
    'Score2': [88, 85, 80, 95]
}

df = pd.DataFrame(data)
print("Dataset:")
print(df)

plt.figure(figsize=(6,4))
plt.hist(df['Score1'], bins=5, color='skyblue', edgecolor='black')
plt.title('Histogram of Score1')
plt.xlabel('Score1')
plt.ylabel('Frequency')
plt.show()

plt.figure(figsize=(6,4))
plt.boxplot([df['Score1'], df['Score2']], labels=['Score1', 'Score2'])
plt.title('Box Plot of Scores')
plt.show()

plt.figure(figsize=(6,4))
plt.bar(df['Name'], df['Score1'], color='orange')
plt.title('Bar Chart of Score1 by Name')
plt.xlabel('Name')
plt.ylabel('Score1')
plt.show()

plt.figure(figsize=(6,6))
plt.pie(df['Score1'], labels=df['Name'], autopct='%1.1f%%', colors=['red','green','blue','yellow'])
plt.title('Pie Chart of Score1')
plt.show()

Comments

Popular posts from this blog

Dijkstra's Algorithm Matrix

k means JDK java

Chi square test