AIHero123's picture Colinyyy's picture
Duplicate from Colinyyy/ChartM3
d2ebfdb
Raw History Blame Contribute Delete
1.19 kB
from io import StringIO
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from matplotlib.patheffects import SimpleLineShadow, Normal
data = {"Region": ["North America", "Latin America", "Europe", "Africa", "Asia", "Australia", "Antarctica", "East Asia", "Middle East"],
"Home schooling rate": [5, 8, 10, 3, 7, 11, 1, 6, 4]}
df = pd.DataFrame(data)
fig, ax = plt.subplots()
x = np.arange(len(df["Region"]))
# Changed line color to green and marker color to red
line, = ax.plot(x, df["Home schooling rate"], marker='D', linestyle='-', linewidth=2, markersize=6, color='green', markerfacecolor='red', alpha=0.8, label="Home schooling rate", zorder=3, path_effects=[SimpleLineShadow(offset=(2.39, 3.87)), Normal()])
for i in range(len(x)):
ax.text(i, df["Home schooling rate"][i], df["Home schooling rate"][i], ha='center')
ax.set_xlabel('Region')
ax.set_ylabel('Home Schooling Rate (%)')
ax.set_title('Home Schooling Rates by Region')
ax.legend(loc='upper right', shadow=True)
ax.set_xticks(x)
ax.set_xticklabels(df["Region"], rotation=45)
ax.grid(True)
ax.set_facecolor('lightgray')
plt.tight_layout()
plt.savefig("Edit_figure.png")