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)
sns.distplot(x, label="a", color="0.25")
sns.distplot(y, label="b", color="0.25")

# add legends
# SOLUTION START
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()
assert ax.legend_ is not None, "there should be a legend"
assert ax.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

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

# make a two columns and one row subplots. Plot y over x in each subplot.
# Give the plot a global title "Figure"
# SOLUTION START
fig = plt.figure(constrained_layout=True)
axs = fig.subplots(1, 2)
for ax in axs.flat:
    ax.plot(x, y)
fig.suptitle("Figure")
# 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.axes[0].get_gridspec().ncols == 2
assert f.axes[0].get_gridspec().nrows == 1
assert f._suptitle.get_text() == "Figure"
for ax in f.axes:
    assert 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
# Show legend and use the greek letter lambda as the legend label
# SOLUTION START
plt.plot(y, x, label=r"$\lambda$")
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()
assert ax.get_legend().get_texts()[0].get_text() == "$\\lambda$"
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 full line from (0,0) to (1,2)
# SOLUTION START
p1 = (0, 0)
p2 = (1, 2)
plt.axline(p1, p2)
# 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._AxLine)
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 a scatter plot with values in x and y
# Plot the data points to have red inside and have black border
# SOLUTION START
plt.scatter(x, y, c="red", 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) > 0
assert len(ax.collections[0]._edgecolors) == 1
assert len(ax.collections[0]._facecolors) == 1
assert tuple(ax.collections[0]._edgecolors[0]) == (0.0, 0.0, 0.0, 1.0)
assert tuple(ax.collections[0]._facecolors[0]) == (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 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 xlabel as "X"
# put the x label at the right end of the x axis
# SOLUTION START
plt.plot(x, y)
ax = plt.gca()
label = ax.set_xlabel("X", fontsize=9)
ax.xaxis.set_label_coords(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()
label = ax.xaxis.get_label()
assert label.get_text() == "X"
assert label.get_position()[0] > 0.8
assert label.get_position()[0] < 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

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

# Show a legend of this plot and show two markers on the line
# SOLUTION START
plt.legend(numpoints=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().numpoints == 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(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)