import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x and use the greek letter phi for title. Bold the title and make sure phi is bold.
# SOLUTION START
plt.plot(y, x)
plt.title(r"$\mathbf{\phi}$")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert "\\phi" in ax.get_title()
assert "bf" in ax.get_title()
assert "$" in ax.get_title()
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# plot y over x on a 2 by 2 subplots with a figure size of (15, 15)
# repeat the plot in each subplot
# SOLUTION START
f, axs = plt.subplots(2, 2, figsize=(15, 15))
for ax in f.axes:
    ax.plot(x, y)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
assert (f.get_size_inches() == (15, 15)).all()
for ax in f.axes:
    assert len(ax.get_lines()) == 1
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

y = 2 * np.random.rand(10)
x = np.arange(10)
plt.plot(x, y)
myTitle = "Some really really long long long title I really really need - and just can't - just can't - make it any - simply any - shorter - at all."

# fit a very long title myTitle into multiple lines
# SOLUTION START
# set title
# plt.title(myTitle, loc='center', wrap=True)
from textwrap import wrap

ax = plt.gca()
ax.set_title("\n".join(wrap(myTitle, 60)), loc="center", wrap=True)
# axes.set_title("\n".join(wrap(myTitle, 60)), loc='center', wrap=True)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
fg = plt.gcf()
assert fg.get_size_inches()[0] < 8
ax = plt.gca()
assert ax.get_title().startswith(myTitle[:10])
assert "\n" in ax.get_title()
assert len(ax.get_title()) >= len(myTitle)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.arange(10)
y = 2 * np.random.rand(10)

# draw a regular matplotlib style plot using seaborn
# SOLUTION START
sns.lineplot(x=x, y=y)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
l = ax.lines[0]
xp, yp = l.get_xydata().T
np.testing.assert_array_almost_equal(xp, x)
np.testing.assert_array_almost_equal(yp, y)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.arange(10)

# draw a line (with random y) for each different line style
# SOLUTION START
from matplotlib import lines

styles = lines.lineStyles.keys()
nstyles = len(styles)
for i, sty in enumerate(styles):
    y = np.random.randn(*x.shape)
    plt.plot(x, y, sty)
# print(lines.lineMarkers.keys())
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
# there should be lines each having a different style
ax = plt.gca()
from matplotlib import lines

assert len(lines.lineStyles.keys()) == len(ax.lines)
allstyles = lines.lineStyles.keys()
for l in ax.lines:
    sty = l.get_linestyle()
    assert sty in allstyles
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import matplotlib.pyplot as plt

H = np.random.randn(10, 10)

# color plot of the 2d array H
# SOLUTION START
plt.imshow(H, interpolation="none")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.images) == 1
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.random.randn(10)
y = np.random.randn(10)

# in plt.plot(x, y), use a plus marker and give it a thickness of 7
# SOLUTION START
plt.plot(x, y, "+", mew=7, ms=20)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.lines) == 1
assert ax.lines[0].get_markeredgewidth() == 7
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.random.rand(10)
y = np.random.rand(10)
plt.scatter(x, y)

# how to turn on minor ticks on x axis only
# SOLUTION START
plt.minorticks_on()
ax = plt.gca()
ax.tick_params(axis="y", which="minor", tick1On=False)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
# x axis has no minor ticks
# y axis has minor ticks
ax = plt.gca()
assert len(ax.collections) == 1
xticks = ax.xaxis.get_minor_ticks()
assert len(xticks) > 0, "there should be some x ticks"
for t in xticks:
    assert t.tick1line.get_visible(), "x tick1lines should be visible"

yticks = ax.yaxis.get_minor_ticks()
for t in yticks:
    assert not t.tick1line.get_visible(), "y tick1line should not be visible"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x in a line chart and label the line "y over x"
# Show legend of the plot and give the legend box a title
# SOLUTION START
plt.plot(x, y, label="y over x")
plt.legend(title="legend")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.get_legend().get_texts()) > 0
assert len(ax.get_legend().get_title().get_text()) > 0
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Make a scatter plot with x and y
# Use star hatch for the marker
# SOLUTION START
plt.scatter(x, y, hatch="*")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert ax.collections[0].get_hatch() is not None
assert "*" in ax.collections[0].get_hatch()[0]
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)
plt.plot(x, y, label="Line")
plt.plot(y, x, label="Flipped")

# Show a two columns legend of this plot
# SOLUTION START
plt.legend(ncol=2)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert ax.get_legend()._ncol == 2
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt

# Make a solid vertical line at x=3 and label it "cutoff". Show legend of this plot.
# SOLUTION START
plt.axvline(x=3, label="cutoff")
plt.legend()
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
plt.show()
assert len(ax.get_lines()) == 1
assert ax.get_lines()[0]._x[0] == 3
assert len(ax.legend_.get_lines()) == 1
assert ax.legend_.get_texts()[0].get_text() == "cutoff"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt

# draw vertical lines at [0.22058956, 0.33088437, 2.20589566]
# SOLUTION START
plt.axvline(x=0.22058956)
plt.axvline(x=0.33088437)
plt.axvline(x=2.20589566)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
data = [0.22058956, 0.33088437, 2.20589566]
ax = plt.gca()
assert len(ax.lines) == 3
for l in ax.lines:
    assert l.get_xdata()[0] in data
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.linspace(0, 2 * np.pi, 400)
y1 = np.sin(x)
y2 = np.cos(x)

# plot x vs y1 and x vs y2 in two subplots, sharing the x axis
# SOLUTION START
fig, (ax1, ax2) = plt.subplots(nrows=2, sharex=True)

plt.subplots_adjust(hspace=0.0)
ax1.grid()
ax2.grid()

ax1.plot(x, y1, color="r")
ax2.plot(x, y2, color="b", linestyle="--")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
fig = plt.gcf()
ax12 = fig.axes
assert len(ax12) == 2
ax1, ax2 = ax12
x1 = ax1.get_xticks()
x2 = ax2.get_xticks()
np.testing.assert_equal(x1, x2)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

from numpy import *
import math
import matplotlib
import matplotlib.pyplot as plt

t = linspace(0, 2 * math.pi, 400)
a = sin(t)
b = cos(t)
c = a + b

# Plot a, b, c in the same figure
# SOLUTION START
plt.plot(t, a, t, b, t, c)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
lines = ax.get_lines()
assert len(lines) == 3
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.arange(10)
y = np.sin(x)
df = pd.DataFrame({"x": x, "y": y})
sns.lineplot(x="x", y="y", data=df)

# remove x tick labels
# SOLUTION START
ax = plt.gca()
ax.set(xticklabels=[])
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
lbl = ax.get_xticklabels()
ticks = ax.get_xticks()
for t, tk in zip(lbl, ticks):
    assert t.get_position()[0] == tk, "tick might not been set, so the default was used"
    assert t.get_text() == "", "the text should be non-empty"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

df = pd.DataFrame(
    np.random.randn(50, 4),
    index=pd.date_range("1/1/2000", periods=50),
    columns=list("ABCD"),
)
df = df.cumsum()

# make four line plots of data in the data frame
# show the data points  on the line plot
# SOLUTION START
df.plot(style=".-")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert ax.get_lines()[0].get_linestyle() != "None"
assert ax.get_lines()[0].get_marker() != "None"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.random.randn(10)
y = np.random.randn(10)

# in a scatter plot of x, y, make the points have black borders and blue face
# SOLUTION START
plt.scatter(x, y, c="blue", edgecolors="black")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.collections) == 1
edgecolors = ax.collections[0].get_edgecolors()
assert edgecolors.shape[0] == 1
assert np.allclose(edgecolors[0], [0.0, 0.0, 0.0, 1.0])
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = sns.load_dataset("exercise")

# Make catplots of scatter plots by using "time" as x, "pulse" as y, "kind" as hue, and "diet" as col
# Change the xlabels to "Exercise Time" and "Exercise Time"
# SOLUTION START
g = sns.catplot(x="time", y="pulse", hue="kind", col="diet", data=df)
axs = g.axes.flatten()
axs[0].set_xlabel("Exercise Time")
axs[1].set_xlabel("Exercise Time")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
axs = plt.gcf().axes
assert axs[0].get_xlabel() == "Exercise Time"
assert axs[1].get_xlabel() == "Exercise Time"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = sns.load_dataset("penguins")[["bill_length_mm", "species", "sex"]]

# Use seaborn factorpot to plot multiple barplots of "bill_length_mm" over "sex" and separate into different subplot columns by "species"
# Do not share y axis across subplots
# SOLUTION START
sns.factorplot(
    x="sex", col="species", y="bill_length_mm", data=df, kind="bar", sharey=False
)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
assert len(f.axes) == 3
for ax in f.axes:
    assert ax.get_xlabel() == "sex"
    assert len(ax.patches) == 2
assert f.axes[0].get_ylabel() == "bill_length_mm"

assert len(f.axes[0].get_yticks()) != len(f.axes[1].get_yticks()) or not np.allclose(
    f.axes[0].get_yticks(), f.axes[1].get_yticks()
)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

points = [(3, 5), (5, 10), (10, 150)]

# plot a line plot for points in points.
# Make the y-axis log scale
# SOLUTION START
plt.plot(*zip(*points))
plt.yscale("log")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.get_lines()) == 1
assert np.all(ax.get_lines()[0]._xy == np.array(points))
assert ax.get_yscale() == "log"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt

l = ["a", "b", "c"]
data = [225, 90, 50]

# Make a donut plot of using `data` and use `l` for the pie labels
# Set the wedge width to be 0.4
# SOLUTION START
plt.pie(data, labels=l, wedgeprops=dict(width=0.4))
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
import matplotlib

ax = plt.gca()
count = 0
text_labels = []
for c in ax.get_children():
    if isinstance(c, matplotlib.patches.Wedge):
        count += 1
        assert c.width == 0.4
    if isinstance(c, matplotlib.text.Text):
        text_labels.append(c.get_text())

for _label in l:
    assert _label in text_labels

assert count == 3
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.boxplot(x="day", y="total_bill", data=tips)

# set the y axis limit to be 0 to 40
# SOLUTION START
plt.ylim(0, 40)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
# should have some shaded regions
ax = plt.gca()
yaxis = ax.get_yaxis()
np.testing.assert_allclose(ax.get_ybound(), [0, 40])
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt
import numpy

xlabels = list("ABCD")
ylabels = list("CDEF")
rand_mat = numpy.random.rand(4, 4)

# Plot of heatmap with data in rand_mat and use xlabels for x-axis labels and ylabels as the y-axis labels
# Make the x-axis tick labels appear on top of the heatmap and invert the order or the y-axis labels (C to F from top to bottom)
# SOLUTION START
plt.pcolor(rand_mat)
plt.xticks(numpy.arange(0.5, len(xlabels)), xlabels)
plt.yticks(numpy.arange(0.5, len(ylabels)), ylabels)
ax = plt.gca()
ax.invert_yaxis()
ax.xaxis.tick_top()
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert ax.get_ylim()[0] > ax.get_ylim()[1]
assert ax.xaxis._major_tick_kw["tick2On"]
assert ax.xaxis._major_tick_kw["label2On"]
assert not ax.xaxis._major_tick_kw["tick1On"]
assert not ax.xaxis._major_tick_kw["label1On"]
assert len(ax.get_xticklabels()) == len(xlabels)
assert len(ax.get_yticklabels()) == len(ylabels)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt
import numpy as np

d = np.random.random((10, 10))

# Use matshow to plot d and make the figure size (8, 8)
# SOLUTION START
matfig = plt.figure(figsize=(8, 8))
plt.matshow(d, fignum=matfig.number)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
assert tuple(f.get_size_inches()) == (8.0, 8.0)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x and label the x axis as "X"
# Make both the x axis ticks and the axis label red
# SOLUTION START
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y)
ax.set_xlabel("X", c="red")
ax.xaxis.label.set_color("red")
ax.tick_params(axis="x", colors="red")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
plt.show()
assert ax.xaxis.label._color in ["red", "r"] or ax.xaxis.label._color == (
    1.0,
    0.0,
    0.0,
    1.0,
)
assert ax.xaxis._major_tick_kw["color"] in ["red", "r"] or ax.xaxis._major_tick_kw[
    "color"
] == (1.0, 0.0, 0.0, 1.0)
assert ax.xaxis._major_tick_kw["labelcolor"] in ["red", "r"] or ax.xaxis._major_tick_kw[
    "color"
] == (1.0, 0.0, 0.0, 1.0)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import matplotlib.pyplot as plt

H = np.random.randn(10, 10)

# show the 2d array H in black and white
# SOLUTION START
plt.imshow(H, cmap="gray")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
import matplotlib

ax = plt.gca()
assert len(ax.images) == 1
assert isinstance(ax.images[0].cmap, matplotlib.colors.LinearSegmentedColormap)
assert ax.images[0].cmap.name == "gray"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib
import matplotlib.pyplot as plt
import pandas as pd

df = pd.DataFrame(
    {
        "celltype": ["foo", "bar", "qux", "woz"],
        "s1": [5, 9, 1, 7],
        "s2": [12, 90, 13, 87],
    }
)

# For data in df, make a bar plot of s1 and s1 and use celltype as the xlabel
# Make the x-axis tick labels rotate 45 degrees
# SOLUTION START
df = df[["celltype", "s1", "s2"]]
df.set_index(["celltype"], inplace=True)
df.plot(kind="bar", alpha=0.75, rot=45)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
plt.show()
assert len(ax.patches) > 0
assert len(ax.xaxis.get_ticklabels()) > 0
for t in ax.xaxis.get_ticklabels():
    assert t._rotation == 45
all_ticklabels = [t.get_text() for t in ax.xaxis.get_ticklabels()]
for cell in ["foo", "bar", "qux", "woz"]:
    assert cell in all_ticklabels
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = sns.load_dataset("penguins")[
    ["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"]
]
sns.distplot(df["bill_length_mm"], color="blue")

# Plot a vertical line at 55 with green color
# SOLUTION START
plt.axvline(55, color="green")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
import matplotlib

ax = plt.gca()
assert len(ax.lines) == 2
assert isinstance(ax.lines[1], matplotlib.lines.Line2D)
assert tuple(ax.lines[1].get_xdata()) == (55, 55)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt
import numpy as np

# Specify the values of blue bars (height)
blue_bar = (23, 25, 17)
# Specify the values of orange bars (height)
orange_bar = (19, 18, 14)

# Plot the blue bar and the orange bar side-by-side in the same bar plot.
# Make  sure the bars don't overlap with each other.
# SOLUTION START
# Position of bars on x-axis
ind = np.arange(len(blue_bar))

# Figure size
plt.figure(figsize=(10, 5))

# Width of a bar
width = 0.3
plt.bar(ind, blue_bar, width, label="Blue bar label")
plt.bar(ind + width, orange_bar, width, label="Orange bar label")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.patches) == 6
x_positions = [rec.get_x() for rec in ax.patches]
assert len(x_positions) == len(set(x_positions))
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)
fig, ax = plt.subplots(1, 1)
plt.xlim(1, 10)
plt.xticks(range(1, 10))
ax.plot(y, x)

# change the second x axis tick label to "second" but keep other labels in numerical
# SOLUTION START
a = ax.get_xticks().tolist()
a[1] = "second"
ax.set_xticklabels(a)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert ax.xaxis.get_ticklabels()[1]._text == "second"
assert ax.xaxis.get_ticklabels()[0]._text == "1"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt

fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(8, 6))
axes = axes.flatten()

for ax in axes:
    ax.set_ylabel(r"$\ln\left(\frac{x_a-x_b}{x_a-x_c}\right)$")
    ax.set_xlabel(r"$\ln\left(\frac{x_a-x_d}{x_a-x_e}\right)$")

plt.show()
plt.clf()

# Copy the previous plot but adjust the subplot padding to have enough space to display axis labels
# SOLUTION START
fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(8, 6))
axes = axes.flatten()

for ax in axes:
    ax.set_ylabel(r"$\ln\left(\frac{x_a-x_b}{x_a-x_c}\right)$")
    ax.set_xlabel(r"$\ln\left(\frac{x_a-x_d}{x_a-x_e}\right)$")

plt.tight_layout()
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
assert tuple(f.get_size_inches()) == (8, 6)
assert f.subplotpars.hspace > 0.2
assert f.subplotpars.wspace > 0.2
assert len(f.axes) == 4
for ax in f.axes:
    assert (
        ax.xaxis.get_label().get_text()
        == "$\\ln\\left(\\frac{x_a-x_d}{x_a-x_e}\\right)$"
    )
    assert (
        ax.yaxis.get_label().get_text()
        == "$\\ln\\left(\\frac{x_a-x_b}{x_a-x_c}\\right)$"
    )
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x in a line chart. Show x axis ticks on both top and bottom of the figure.
# SOLUTION START
plt.plot(x, y)
plt.tick_params(top=True)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert ax.xaxis._major_tick_kw["tick2On"]
assert ax.xaxis._major_tick_kw["tick1On"]
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)
a = np.arange(10)
z = np.arange(10)

# Plot y over x and a over z in two side-by-side subplots.
# Label them "y" and "a" and make a single figure-level legend using the figlegend function
# SOLUTION START
fig, axs = plt.subplots(1, 2)
axs[0].plot(x, y, label="y")
axs[1].plot(z, a, label="a")
plt.figlegend(["y", "a"])
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
assert len(f.legends) > 0
for ax in f.axes:
    assert ax.get_legend() is None or not ax.get_legend()._visible
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.arange(10)
y = np.random.randn(10)
plt.scatter(x, y)

# show grids
# SOLUTION START
ax = plt.gca()
ax.grid(True)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
xlines = ax.get_xaxis()
l = xlines.get_gridlines()[0]
assert l.get_visible()

ylines = ax.get_yaxis()
l = ylines.get_gridlines()[0]
assert l.get_visible()

assert len(ax.lines) == 0
assert len(ax.collections) == 1
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = 10 * np.random.randn(10)

plt.plot(x)

# highlight in red the x range 2 to 4
# SOLUTION START
plt.axvspan(2, 4, color="red", alpha=1)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
import matplotlib

ax = plt.gca()
assert len(ax.patches) == 1
assert isinstance(ax.patches[0], matplotlib.patches.Polygon)
assert ax.patches[0].get_xy().min(axis=0)[0] == 2
assert ax.patches[0].get_xy().max(axis=0)[0] == 4
assert ax.patches[0].get_facecolor()[0] > 0
assert ax.patches[0].get_facecolor()[1] < 0.1
assert ax.patches[0].get_facecolor()[2] < 0.1
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt

a, b = 1, 1
c, d = 3, 4

# draw a line that pass through (a, b) and (c, d)
# do not just draw a line segment
# set the xlim and ylim to be between 0 and 5
# SOLUTION START
plt.axline((a, b), (c, d))
plt.xlim(0, 5)
plt.ylim(0, 5)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()

import matplotlib

assert len(ax.get_lines()) == 1
assert isinstance(ax.get_lines()[0], matplotlib.lines._AxLine)
assert ax.get_xlim()[0] == 0 and ax.get_xlim()[1] == 5
assert ax.get_ylim()[0] == 0 and ax.get_ylim()[1] == 5
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.linspace(0, 2 * np.pi, 10)
y = np.cos(x)

# set legend title to xyz and set the title font to size 20
# SOLUTION START
# plt.figure()
plt.plot(x, y, label="sin")
ax = plt.gca()
ax.legend(title="xyz", title_fontsize=20)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
l = ax.get_legend()
t = l.get_title()
assert t.get_fontsize() == 20
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# draw a line segment from (0,0) to (1,2)
# SOLUTION START
p1 = (0, 0)
p2 = (1, 2)
plt.plot((p1[0], p2[0]), (p1[1], p2[1]))
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
import matplotlib

ax = plt.gca()
assert len(ax.get_lines()) == 1
assert isinstance(ax.get_lines()[0], matplotlib.lines.Line2D)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.random.random((10, 2))

# Plot each column in x as an individual line and label them as "a" and "b"
# SOLUTION START
[a, b] = plt.plot(x)
plt.legend([a, b], ["a", "b"])
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.legend_.get_texts()) == 2
assert tuple([l._text for l in ax.legend_.get_texts()]) == ("a", "b")
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x
# Turn minor ticks on and show gray dashed minor grid lines
# Do not show any major grid lines
# SOLUTION START
plt.plot(y, x)
plt.minorticks_on()
plt.grid(color="gray", linestyle="dashed", which="minor")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert not ax.xaxis._major_tick_kw["gridOn"]
assert ax.xaxis._minor_tick_kw["gridOn"]
assert not ax.yaxis._major_tick_kw["gridOn"]
assert ax.yaxis._minor_tick_kw["gridOn"]
assert ax.xaxis._minor_tick_kw["tick1On"]
assert "grid_linestyle" in ax.xaxis._minor_tick_kw
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import matplotlib.pyplot as plt

data = [1000, 1000, 5000, 3000, 4000, 16000, 2000]

# Make a histogram of data and renormalize the data to sum up to 1
# Format the y tick labels into percentage and set y tick labels as 10%, 20%, etc.
# SOLUTION START
plt.hist(data, weights=np.ones(len(data)) / len(data))
from matplotlib.ticker import PercentFormatter

ax = plt.gca()
ax.yaxis.set_major_formatter(PercentFormatter(1))
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
import matplotlib

s = 0
ax = plt.gca()
plt.show()
for rec in ax.get_children():
    if isinstance(rec, matplotlib.patches.Rectangle):
        s += rec._height
assert s == 2.0
for l in ax.get_yticklabels():
    assert "%" in l.get_text()
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x in a line chart and name axis with labels ("x" and "y")
# Hide tick labels but keep axis labels
# SOLUTION START
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.set_xlabel("x")
ax.set_ylabel("y")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.get_lines()) > 0
no_tick_label = np.all([l._text == "" for l in ax.get_xaxis().get_majorticklabels()])
tick_not_visible = not ax.get_xaxis()._visible
ax.get_xaxis()

assert no_tick_label or tick_not_visible
assert ax.get_xaxis().get_label().get_text() == "x"
assert ax.get_yaxis().get_label().get_text() == "y"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x in a line chart and label the line "y over x"
# Show legend of the plot and give the legend box a title  "Legend"
# Bold the legend title
# SOLUTION START
plt.plot(x, y, label="y over x")
plt.legend(title="legend", title_fontproperties={"weight": "bold"})
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.get_legend().get_texts()) > 0
assert len(ax.get_legend().get_title().get_text()) > 0
assert "bold" in ax.get_legend().get_title().get_fontweight()
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x
# Label the x-axis as "X"
# Set the space between the x-axis label and the x-axis to be 20
# SOLUTION START
plt.plot(x, y)
plt.xlabel("X", labelpad=20)
plt.tight_layout()
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert ax.xaxis.labelpad == 20
assert ax.get_xlabel() == "X"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.random.rand(10)
y = np.random.rand(10)
plt.scatter(x, y)

# how to turn on minor ticks on y axis only
# SOLUTION START
plt.minorticks_on()
ax = plt.gca()
ax.tick_params(axis="x", which="minor", bottom=False)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
# x axis has no minor ticks
# y axis has minor ticks
ax = plt.gca()
assert len(ax.collections) == 1
xticks = ax.xaxis.get_minor_ticks()
for t in xticks:
    assert not t.tick1line.get_visible()

yticks = ax.yaxis.get_minor_ticks()
assert len(yticks) > 0
for t in yticks:
    assert t.tick1line.get_visible()
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import pandas as pd
import matplotlib.pyplot as plt

values = [[1, 2], [3, 4]]
df = pd.DataFrame(values, columns=["Type A", "Type B"], index=["Index 1", "Index 2"])

# Plot values in df with line chart
# label the x axis and y axis in this plot as "X" and "Y"
# SOLUTION START
df.plot()
plt.xlabel("X")
plt.ylabel("Y")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.get_lines()) == 2
assert ax.xaxis.label._text == "X"
assert ax.yaxis.label._text == "Y"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = sns.load_dataset("penguins")[
    ["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"]
]

# make a seaborn scatter plot of bill_length_mm and bill_depth_mm
# use markersize 30 for all data points in the scatter plot
# SOLUTION START
sns.scatterplot(x="bill_length_mm", y="bill_depth_mm", data=df, s=30)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.collections[0].get_sizes()) == 1
assert ax.collections[0].get_sizes()[0] == 30
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x with a legend of "Line"
# Adjust the spacing between legend markers and labels to be 0.1
# SOLUTION START
plt.plot(x, y, label="Line")
plt.legend(handletextpad=0.1)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.get_legend().get_texts()) > 0
assert ax.get_legend().handletextpad == 0.1
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.arange(10)
y = np.sin(x)
df = pd.DataFrame({"x": x, "y": y})
sns.lineplot(x="x", y="y", data=df)

# remove x axis label
# SOLUTION START
ax = plt.gca()
ax.set(xlabel=None)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
lbl = ax.get_xlabel()
assert lbl == ""
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.arange(10)

# draw a line (with random y) for each different line style
# SOLUTION START
from matplotlib import lines

styles = lines.lineMarkers
nstyles = len(styles)
for i, sty in enumerate(styles):
    y = np.random.randn(*x.shape)
    plt.plot(x, y, marker=sty)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
# there should be lines each having a different style
ax = plt.gca()
from matplotlib import lines

all_markers = lines.lineMarkers
assert len(all_markers) == len(ax.lines)

actual_markers = [l.get_marker() for l in ax.lines]
assert len(set(actual_markers).difference(all_markers)) == 0
assert len(set(all_markers).difference(set(actual_markers + [None]))) == 0
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Make a scatter plot with x and y and set marker size to be 100
# Combine star hatch and vertical line hatch together for the marker
# SOLUTION START
plt.scatter(x, y, hatch="*|", s=500)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert ax.collections[0].get_sizes()[0] == 500
assert ax.collections[0].get_hatch() is not None
assert "*" in ax.collections[0].get_hatch()
assert "|" in ax.collections[0].get_hatch()
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

df = pd.DataFrame(
    {
        "id": ["1", "2", "1", "2", "2"],
        "x": [123, 22, 356, 412, 54],
        "y": [120, 12, 35, 41, 45],
    }
)

# Use seaborn to make a pairplot of data in `df` using `x` for x_vars, `y` for y_vars, and `id` for hue
# Hide the legend in the output figure
# SOLUTION START
g = sns.pairplot(df, x_vars=["x"], y_vars=["y"], hue="id")
g._legend.remove()
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
assert len(f.axes) == 1
if len(f.legends) == 0:
    for ax in f.axes:
        if ax.get_legend() is not None:
            assert not ax.get_legend()._visible
else:
    for l in f.legends:
        assert not l._visible
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)
plt.plot(x, y)

# Remove the margin before the first ytick but use greater than zero margin for the xaxis
# SOLUTION START
plt.margins(y=0)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert ax.margins()[0] > 0
assert ax.margins()[1] == 0
assert ax.get_xlim()[0] < 0
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.random.randn(10)
y = np.random.randn(10)

(l,) = plt.plot(range(10), "o-", lw=5, markersize=30)

# make the border of the markers solid black
# SOLUTION START
l.set_markeredgecolor((0, 0, 0, 1))
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
l = ax.lines[0]
assert l.get_markeredgecolor() == (0, 0, 0, 1)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# plot y over x
# use a tick interval of 1 on the a-axis
# SOLUTION START
plt.plot(x, y)
plt.xticks(np.arange(min(x), max(x) + 1, 1.0))
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
xticks = ax.get_xticks()
assert (
    ax.get_xticks() == np.arange(ax.get_xticks().min(), ax.get_xticks().max() + 1, 1)
).all()
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.linspace(0, 2 * np.pi, 10)
y = np.cos(x)

plt.plot(x, y, label="sin")

# show legend and set the font to size 20
# SOLUTION START
plt.rcParams["legend.fontsize"] = 20
plt.legend(title="xxx")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
l = ax.get_legend()
assert l.get_texts()[0].get_fontsize() == 20
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.random.randn(10)
y = np.random.randn(10)

(l,) = plt.plot(range(10), "o-", lw=5, markersize=30)

# set the face color of the markers to have an alpha (transparency) of 0.2
# SOLUTION START
l.set_markerfacecolor((1, 1, 0, 0.2))
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
l = ax.lines[0]
assert l.get_markerfacecolor()[3] == 0.2
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.random.rand(10)
y = np.random.rand(10)

# Make a histogram of x and show outline of each bar in the histogram
# Make the outline of each bar has a line width of 1.2
# SOLUTION START
plt.hist(x, edgecolor="black", linewidth=1.2)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
import matplotlib

ax = plt.gca()
assert len(ax.patches) > 0
for rec in ax.get_children():
    if isinstance(rec, matplotlib.patches.Rectangle):
        if rec.xy != (0, 0):
            assert rec.get_edgecolor() != rec.get_facecolor()
            assert rec.get_linewidth() == 1.2
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(11)
y = np.arange(11)
plt.xlim(0, 10)
plt.ylim(0, 10)

# Plot a scatter plot x over y and set both the x limit and y limit to be between 0 and 10
# Turn off axis clipping so data points can go beyond the axes
# SOLUTION START
plt.scatter(x, y, clip_on=False)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert not ax.collections[0].get_clip_on()
assert ax.get_xlim() == (0.0, 10.0)
assert ax.get_ylim() == (0.0, 10.0)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.random.random((10, 10))
from matplotlib import gridspec

nrow = 2
ncol = 2

fig = plt.figure(figsize=(ncol + 1, nrow + 1))

# Make a 2x2 subplots with fig and plot x in each subplot as an image
# Remove the space between each subplot and make the subplot adjacent to each other
# Remove the axis ticks from each subplot
# SOLUTION START
gs = gridspec.GridSpec(
    nrow,
    ncol,
    wspace=0.0,
    hspace=0.0,
    top=1.0 - 0.5 / (nrow + 1),
    bottom=0.5 / (nrow + 1),
    left=0.5 / (ncol + 1),
    right=1 - 0.5 / (ncol + 1),
)

for i in range(nrow):
    for j in range(ncol):
        ax = plt.subplot(gs[i, j])
        ax.imshow(x)
        ax.set_xticklabels([])
        ax.set_yticklabels([])
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
assert len(f.axes) == 4
for ax in f.axes:
    assert len(ax.images) == 1
    assert ax.get_subplotspec()._gridspec.hspace == 0.0
    assert ax.get_subplotspec()._gridspec.wspace == 0.0
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.arange(10)
y = np.random.randn(10)

# line plot x and y with a thick diamond marker
# SOLUTION START
plt.plot(x, y, marker="D")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
# there should be lines each having a different style
ax = plt.gca()
assert ax.lines[0].get_marker() == "D"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

y = 2 * np.random.rand(10)
x = np.arange(10)

# make the y axis go upside down
# SOLUTION START
ax = plt.gca()
ax.invert_yaxis()
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
plt.show()
assert ax.get_ylim()[0] > ax.get_ylim()[1]
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = sns.load_dataset("penguins")[["bill_length_mm", "species", "sex"]]

# Make a stripplot for the data in df. Use "sex" as x, "bill_length_mm" as y, and "species" for the color
# Remove the legend from the stripplot
# SOLUTION START
ax = sns.stripplot(x="sex", y="bill_length_mm", hue="species", data=df)
ax.legend_.remove()
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
assert len(f.axes) == 1
ax = plt.gca()
assert len(ax.collections) > 0
assert ax.legend_ is None or not ax.legend_._visible
assert ax.get_xlabel() == "sex"
assert ax.get_ylabel() == "bill_length_mm"
all_colors = set()
for c in ax.collections:
    all_colors.add(tuple(c.get_facecolors()[0]))
assert len(all_colors) == 3
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.linspace(0, 2 * np.pi, 10)
y = np.cos(x)
plt.plot(x, y, label="sin")

# rotate the x axis labels counter clockwise by 45 degrees
# SOLUTION START
plt.xticks(rotation=-45)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
x = ax.get_xaxis()
labels = ax.get_xticklabels()
for l in labels:
    assert l.get_rotation() == 360 - 45
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Make two subplots. Make the first subplot three times wider than the second subplot but they should have the same height.
# SOLUTION START
f, (a0, a1) = plt.subplots(1, 2, gridspec_kw={"width_ratios": [3, 1]})
a0.plot(x, y)
a1.plot(y, x)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
width_ratios = f._gridspecs[0].get_width_ratios()
all_axes = f.get_axes()

assert len(all_axes) == 2
assert width_ratios == [3, 1]
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x. Give the plot a title "Figure 1". bold the word "Figure" in the title but do not bold "1"
# SOLUTION START
plt.plot(x, y)
plt.title(r"$\bf{Figure}$ 1")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert "bf" in ax.get_title()
assert "$" in ax.get_title()
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# Plot y over x with a legend of "Line"
# Adjust the length of the legend handle to be 0.3
# SOLUTION START
plt.plot(x, y, label="Line")
plt.legend(handlelength=0.3)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
assert len(ax.get_legend().get_texts()) > 0
assert ax.get_legend().handlelength == 0.3
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.arange(10)
y = np.arange(10)

# make 4 by 4 subplots with a figure size (5,5)
# in each subplot, plot y over x and show axis tick labels
# give enough spacing between subplots so the tick labels don't overlap
# SOLUTION START
fig, axes = plt.subplots(nrows=4, ncols=4, figsize=(5, 5))
for ax in axes.flatten():
    ax.plot(x, y)
fig.tight_layout()
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
f = plt.gcf()
assert f.subplotpars.hspace > 0.2
assert f.subplotpars.wspace > 0.2
assert len(f.axes) == 16
for ax in f.axes:
    assert ax.xaxis._major_tick_kw["tick1On"]
    assert ax.xaxis._major_tick_kw["label1On"]
    assert ax.yaxis._major_tick_kw["tick1On"]
    assert ax.yaxis._major_tick_kw["label1On"]
    assert len(ax.get_xticks()) > 0
    assert len(ax.get_yticks()) > 0
    for l in ax.get_xticklabels():
        assert l.get_text() != ""
    for l in ax.get_yticklabels():
        assert l.get_text() != ""
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.linspace(0, 2 * np.pi, 400)
y1 = np.sin(x)
y2 = np.cos(x)

# plot x vs y1 and x vs y2 in two subplots
# remove the frames from the subplots
# SOLUTION START
fig, (ax1, ax2) = plt.subplots(nrows=2, subplot_kw=dict(frameon=False))

plt.subplots_adjust(hspace=0.0)
ax1.grid()
ax2.grid()

ax1.plot(x, y1, color="r")
ax2.plot(x, y2, color="b", linestyle="--")
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
fig = plt.gcf()
ax12 = fig.axes
assert len(ax12) == 2
ax1, ax2 = ax12
assert not ax1.get_frame_on()
assert not ax2.get_frame_on()
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.arange(10)
y = np.random.randn(10)
plt.scatter(x, y)

# show yticks and horizontal grid at y positions 3 and 4
# show xticks and vertical grid at x positions 1 and 2
# SOLUTION START
ax = plt.gca()
ax.yaxis.set_ticks([3, 4])
ax.yaxis.grid(True)
ax.xaxis.set_ticks([1, 2])
ax.xaxis.grid(True)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
np.testing.assert_equal([3, 4], ax.get_yticks())
np.testing.assert_equal([1, 2], ax.get_xticks())

xlines = ax.get_xaxis()
l = xlines.get_gridlines()[0]
assert l.get_visible()

ylines = ax.get_yaxis()
l = ylines.get_gridlines()[0]
assert l.get_visible()
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy
import pandas
import matplotlib.pyplot as plt
import seaborn

seaborn.set(style="ticks")

numpy.random.seed(0)
N = 37
_genders = ["Female", "Male", "Non-binary", "No Response"]
df = pandas.DataFrame(
    {
        "Height (cm)": numpy.random.uniform(low=130, high=200, size=N),
        "Weight (kg)": numpy.random.uniform(low=30, high=100, size=N),
        "Gender": numpy.random.choice(_genders, size=N),
    }
)

# make seaborn relation plot and color by the gender field of the dataframe df
# SOLUTION START
seaborn.relplot(
    data=df, x="Weight (kg)", y="Height (cm)", hue="Gender", hue_order=_genders
)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
all_colors = set()
for c in ax.collections:
    colors = c.get_facecolor()
    for i in range(colors.shape[0]):
        all_colors.add(tuple(colors[i]))
assert len(all_colors) == 4
assert ax.get_xlabel() == "Weight (kg)"
assert ax.get_ylabel() == "Height (cm)"
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

from matplotlib import pyplot as plt
import numpy as np

x = np.arange(10)
y = np.arange(1, 11)
error = np.random.random(y.shape)

# Plot y over x and show the error according to `error`
# Plot the error as a shaded region rather than error bars
# SOLUTION START
plt.plot(x, y, "k-")
plt.fill_between(x, y - error, y + error)
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
import matplotlib

ax = plt.gca()
assert len(ax.lines) == 1
assert len(ax.collections) == 1
assert isinstance(ax.collections[0], matplotlib.collections.PolyCollection)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.random.randn(10)
y = x
plt.scatter(x, y)

# put y ticks at -1 and 1 only
# SOLUTION START
ax = plt.gca()
ax.set_yticks([-1, 1])
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
np.testing.assert_equal([-1, 1], ax.get_yticks())
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)


import pickle
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--test_case", type=int, default=1)
args = parser.parse_args()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

x = np.random.randn(10)
y = np.random.randn(10)

(l,) = plt.plot(range(10), "o-", lw=5, markersize=30)

# set both line and marker colors to be solid red
# SOLUTION START
l.set_markeredgecolor((1, 0, 0, 1))
l.set_color((1, 0, 0, 1))
# SOLUTION END
plt.savefig('result/plot.png', bbox_inches ='tight')

#Image Testing
from PIL import Image
import numpy as np
code_img = np.array(Image.open('result/plot.png'))
oracle_img = np.array(Image.open('ans/oracle_plot.png'))
sample_image_stat = (
    code_img.shape == oracle_img.shape
    and np.allclose(code_img, oracle_img)
)
if sample_image_stat:
    with open('result/result_1.pkl', 'wb') as file:
        # if image test passed, we save True to the result file
        pickle.dump(True, file)

# Testing
ax = plt.gca()
l = ax.lines[0]
assert l.get_markeredgecolor() == (1, 0, 0, 1)
assert l.get_color() == (1, 0, 0, 1)
assert l.get_markerfacecolor() == (1, 0, 0, 1)
with open('result/result_1.pkl', 'wb') as file:
    # or if execution-based test passed, we save True to the result file
    pickle.dump(True, file)