Prompt:
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

import matplotlib.pyplot as plt
import numpy
from PIL import Image
import numpy as np

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    xlabels = list("ABCD")
    ylabels = list("CDEF")
    rand_mat = numpy.random.rand(4, 4)
    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()
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    xlabels = list("ABCD")
    ylabels = list("CDEF")
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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)
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
import numpy
xlabels = list("ABCD")
ylabels = list("CDEF")
rand_mat = numpy.random.rand(4, 4)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc

rc("mathtext", default="regular")

time = np.arange(10)
temp = np.random.random(10) * 30
Swdown = np.random.random(10) * 100 - 10
Rn = np.random.random(10) * 100 - 10

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(time, Swdown, "-", label="Swdown")
ax.plot(time, Rn, "-", label="Rn")
ax2 = ax.twinx()
ax2.plot(time, temp, "-r", label="temp")
ax.legend(loc=0)
ax.grid()
ax.set_xlabel("Time (h)")
ax.set_ylabel(r"Radiation ($MJ\,m^{-2}\,d^{-1}$)")
ax2.set_ylabel(r"Temperature ($^\circ$C)")
ax2.set_ylim(0, 35)
ax.set_ylim(-20, 100)
plt.show()
plt.clf()

# copy the code of the above plot and edit it to have legend for all three cruves in the two subplots
# SOLUTION START

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    rc("mathtext", default="regular")
    time = np.arange(10)
    temp = np.random.random(10) * 30
    Swdown = np.random.random(10) * 100 - 10
    Rn = np.random.random(10) * 100 - 10
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(time, Swdown, "-", label="Swdown")
    ax.plot(time, Rn, "-", label="Rn")
    ax2 = ax.twinx()
    ax2.plot(time, temp, "-r", label="temp")
    ax.legend(loc=0)
    ax.grid()
    ax.set_xlabel("Time (h)")
    ax.set_ylabel(r"Radiation ($MJ\,m^{-2}\,d^{-1}$)")
    ax2.set_ylabel(r"Temperature ($^\circ$C)")
    ax2.set_ylim(0, 35)
    ax.set_ylim(-20, 100)
    plt.show()
    plt.clf()
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(time, Swdown, "-", label="Swdown")
    ax.plot(time, Rn, "-", label="Rn")
    ax2 = ax.twinx()
    ax2.plot(time, temp, "-r", label="temp")
    ax.legend(loc=0)
    ax.grid()
    ax.set_xlabel("Time (h)")
    ax.set_ylabel(r"Radiation ($MJ\,m^{-2}\,d^{-1}$)")
    ax2.set_ylabel(r"Temperature ($^\circ$C)")
    ax2.set_ylim(0, 35)
    ax.set_ylim(-20, 100)
    ax2.legend(loc=0)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        f = plt.gcf()
        plt.show()
        assert len(f.axes) == 2
        assert len(f.axes[0].get_lines()) == 2
        assert len(f.axes[1].get_lines()) == 1
        assert len(f.axes[0]._twinned_axes.get_siblings(f.axes[0])) == 2
        if len(f.legends) == 1:
            assert len(f.legends[0].get_texts()) == 3
        elif len(f.legends) > 1:
            assert False
        else:
            assert len(f.axes[0].get_legend().get_texts()) == 2
            assert len(f.axes[1].get_legend().get_texts()) == 1
    return 1

exec_context = r"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
rc("mathtext", default="regular")
time = np.arange(10)
temp = np.random.random(10) * 30
Swdown = np.random.random(10) * 100 - 10
Rn = np.random.random(10) * 100 - 10
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(time, Swdown, "-", label="Swdown")
ax.plot(time, Rn, "-", label="Rn")
ax2 = ax.twinx()
ax2.plot(time, temp, "-r", label="temp")
ax.legend(loc=0)
ax.grid()
ax.set_xlabel("Time (h)")
ax.set_ylabel(r"Radiation ($MJ\,m^{-2}\,d^{-1}$)")
ax2.set_ylabel(r"Temperature ($^\circ$C)")
ax2.set_ylim(0, 35)
ax.set_ylim(-20, 100)
plt.show()
plt.clf()
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

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

# make two side-by-side subplots and and in each subplot, plot y over x
# Title each subplot as "Y"
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    fig, axs = plt.subplots(1, 2)
    for ax in axs:
        ax.plot(x, y)
        ax.set_title("Y")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        fig = plt.gcf()
        flat_list = fig.axes
        assert len(flat_list) == 2
        if not isinstance(flat_list, list):
            flat_list = flat_list.flatten()
        for ax in flat_list:
            assert ax.get_title() == "Y"
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

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

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    df = sns.load_dataset("penguins")[
        ["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"]
    ]
    sns.scatterplot(x="bill_length_mm", y="bill_depth_mm", data=df, s=30)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.collections[0].get_sizes()) == 1
        assert ax.collections[0].get_sizes()[0] == 30
    return 1

exec_context = r"""
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"]
]
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

a = [2.56422, 3.77284, 3.52623]
b = [0.15, 0.3, 0.45]
c = [58, 651, 393]

# make scatter plot of a over b and annotate each data point with correspond numbers in c
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    a = [2.56422, 3.77284, 3.52623]
    b = [0.15, 0.3, 0.45]
    c = [58, 651, 393]
    fig, ax = plt.subplots()
    plt.scatter(a, b)
    for i, txt in enumerate(c):
        ax.annotate(txt, (a[i], b[i]))
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    c = [58, 651, 393]
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.texts) == 3
        for t in ax.texts:
            assert int(t.get_text()) in c
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
a = [2.56422, 3.77284, 3.52623]
b = [0.15, 0.3, 0.45]
c = [58, 651, 393]
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(x, y, label="y over x")
    plt.legend(title="legend")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.get_legend().get_texts()) > 0
        assert len(ax.get_legend().get_title().get_text()) > 0
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(x, y, label="y over x")
    plt.legend(title="legend", title_fontproperties={"weight": "bold"})
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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()
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image
import matplotlib

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.random.rand(10)
    y = np.random.rand(10)
    plt.hist(x, edgecolor="black", linewidth=1.2)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.random.rand(10)
y = np.random.rand(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    f, (a0, a1) = plt.subplots(1, 2, gridspec_kw={"width_ratios": [3, 1]})
    a0.plot(x, y)
    a1.plot(y, x)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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]
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

x = np.random.rand(10)
y = np.random.rand(10)
bins = np.linspace(-1, 1, 100)

# Plot two histograms of x and y on a single chart with matplotlib
# Set the transparency of the histograms to be 0.5
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.random.rand(10)
    y = np.random.rand(10)
    bins = np.linspace(-1, 1, 100)
    plt.hist(x, bins, alpha=0.5, label="x")
    plt.hist(y, bins, alpha=0.5, label="y")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.patches) > 0
        for p in ax.patches:
            assert p.get_alpha() == 0.5
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.random.rand(10)
y = np.random.rand(10)
bins = np.linspace(-1, 1, 100)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

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

# Plot a grouped histograms of x and y on a single chart with matplotlib
# Use grouped histograms so that the histograms don't overlap with each other
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.random.rand(10)
    y = np.random.rand(10)
    bins = np.linspace(-1, 1, 100)
    plt.hist([x, y])
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        all_xs = []
        all_widths = []
        assert len(ax.patches) > 0
        for p in ax.patches:
            all_xs.append(p.get_x())
            all_widths.append(p.get_width())
        all_xs = np.array(all_xs)
        all_widths = np.array(all_widths)
        sort_ids = all_xs.argsort()
        all_xs = all_xs[sort_ids]
        all_widths = all_widths[sort_ids]
        assert np.all(all_xs[1:] - (all_xs + all_widths)[:-1] > -0.001)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.random.rand(10)
y = np.random.rand(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import matplotlib.pyplot as plt
from PIL import Image
import numpy as np
import matplotlib

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    a, b = 1, 1
    c, d = 3, 4
    plt.axline((a, b), (c, d))
    plt.xlim(0, 5)
    plt.ylim(0, 5)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        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
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
a, b = 1, 1
c, d = 3, 4
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import matplotlib.pyplot as plt
import numpy as np

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

# make two colormaps with x and y and put them into different subplots
# use a single colorbar for these two subplots
# SOLUTION START

import matplotlib.pyplot as plt
import numpy as np
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.random.random((10, 10))
    y = np.random.random((10, 10))
    fig, axes = plt.subplots(nrows=1, ncols=2)
    axes[0].imshow(x, vmin=0, vmax=1)
    im = axes[1].imshow(x, vmin=0, vmax=1)
    fig.subplots_adjust(right=0.8)
    cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
    fig.colorbar(im, cax=cbar_ax)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        f = plt.gcf()
        plt.show()
        assert len(f.get_children()) == 4
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
import numpy as np
x = np.random.random((10, 10))
y = np.random.random((10, 10))
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.random.random((10, 2))
    [a, b] = plt.plot(x)
    plt.legend([a, b], ["a", "b"])
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.legend_.get_texts()) == 2
        assert tuple([l._text for l in ax.legend_.get_texts()]) == ("a", "b")
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.random.random((10, 2))
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

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

# plot y over x and z over a in two different subplots
# Set "Y and Z" as a main title above the two subplots
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    z = np.arange(10)
    a = np.arange(10)
    fig, axes = plt.subplots(nrows=1, ncols=2)
    axes[0].plot(x, y)
    axes[1].plot(a, z)
    plt.suptitle("Y and Z")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        f = plt.gcf()
        assert f._suptitle.get_text() == "Y and Z"
        for ax in f.axes:
            assert ax.get_title() == ""
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
z = np.arange(10)
a = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    points = [(3, 5), (5, 10), (10, 150)]
    plt.plot(*zip(*points))
    plt.yscale("log")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    points = [(3, 5), (5, 10), (10, 150)]
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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"
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
points = [(3, 5), (5, 10), (10, 150)]
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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 font size 20 for title, font size 18 for xlabel and font size 16 for ylabel
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(x, y, label="1")
    plt.title("test title", fontsize=20)
    plt.xlabel("xlabel", fontsize=18)
    plt.ylabel("ylabel", fontsize=16)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        ylabel_font = ax.yaxis.get_label().get_fontsize()
        xlabel_font = ax.xaxis.get_label().get_fontsize()
        title_font = ax.title.get_fontsize()
        assert ylabel_font != xlabel_font
        assert title_font != xlabel_font
        assert title_font != ylabel_font
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import matplotlib.pyplot as plt
import numpy as np

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

f = plt.figure()
ax = f.add_subplot(111)

# plot y over x, show tick labels (from 1 to 10)
# use the `ax` object to set the tick labels
# SOLUTION START

import matplotlib.pyplot as plt
import numpy as np
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    f = plt.figure()
    ax = f.add_subplot(111)
    plt.plot(x, y)
    ax.set_xticks(np.arange(1, 11))
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert np.allclose(ax.get_xticks(), np.arange(1, 11))
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(10)
y = np.arange(10)
f = plt.figure()
ax = f.add_subplot(111)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import numpy as np
import matplotlib.pyplot as plt

lines = [[(0, 1), (1, 1)], [(2, 3), (3, 3)], [(1, 2), (1, 3)]]
c = np.array([(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)])

# Plot line segments according to the positions specified in lines
# Use the colors specified in c to color each line segment
# SOLUTION START

for i in range(len(lines)):
    plt.plot([lines[i][0][0], lines[i][1][0]], [lines[i][0][1], lines[i][1][1]], c=c[i])

import numpy as np
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    lines = [[(0, 1), (1, 1)], [(2, 3), (3, 3)], [(1, 2), (1, 3)]]
    c = np.array([(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)])
    for i in range(len(lines)):
        plt.plot(
            [lines[i][0][0], lines[i][1][0]], [lines[i][0][1], lines[i][1][1]], c=c[i]
        )
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    lines = [[(0, 1), (1, 1)], [(2, 3), (3, 3)], [(1, 2), (1, 3)]]
    c = np.array([(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)])
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.get_lines()) == len(lines)
        for i in range(len(lines)):
            assert np.all(ax.get_lines()[i].get_color() == c[i])
    return 1

exec_context = r"""
import numpy as np
import matplotlib.pyplot as plt
lines = [[(0, 1), (1, 1)], [(2, 3), (3, 3)], [(1, 2), (1, 3)]]
c = np.array([(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)])
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

x = np.arange(0, 1000, 50)
y = np.arange(0, 1000, 50)

# plot y over x on a log-log plot
# mark the axes with numbers like 1, 10, 100. do not use scientific notation
# SOLUTION START

fig, ax = plt.subplots()
ax.plot(x, y)
ax.axis([1, 1000, 1, 1000])
ax.loglog()

from matplotlib.ticker import ScalarFormatter

for axis in [ax.xaxis, ax.yaxis]:
    formatter = ScalarFormatter()
    formatter.set_scientific(False)
    axis.set_major_formatter(formatter)

import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from matplotlib.ticker import ScalarFormatter

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(0, 1000, 50)
    y = np.arange(0, 1000, 50)
    fig, ax = plt.subplots()
    ax.plot(x, y)
    ax.axis([1, 1000, 1, 1000])
    ax.loglog()
    for axis in [ax.xaxis, ax.yaxis]:
        formatter = ScalarFormatter()
        formatter.set_scientific(False)
        axis.set_major_formatter(formatter)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        plt.show()
        assert ax.get_yaxis().get_scale() == "log"
        assert ax.get_xaxis().get_scale() == "log"
        all_ticklabels = [l.get_text() for l in ax.get_xaxis().get_ticklabels()]
        for t in all_ticklabels:
            assert "$\mathdefault" not in t
        for l in ["1", "10", "100"]:
            assert l in all_ticklabels
        all_ticklabels = [l.get_text() for l in ax.get_yaxis().get_ticklabels()]
        for t in all_ticklabels:
            assert "$\mathdefault" not in t
        for l in ["1", "10", "100"]:
            assert l in all_ticklabels
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(0, 1000, 50)
y = np.arange(0, 1000, 50)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    df = pd.DataFrame(
        np.random.randn(50, 4),
        index=pd.date_range("1/1/2000", periods=50),
        columns=list("ABCD"),
    )
    df = df.cumsum()
    df.plot(style=".-")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert ax.get_lines()[0].get_linestyle() != "None"
        assert ax.get_lines()[0].get_marker() != "None"
    return 1

exec_context = r"""
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()
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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))

import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import matplotlib
from matplotlib.ticker import PercentFormatter

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    data = [1000, 1000, 5000, 3000, 4000, 16000, 2000]
    plt.hist(data, weights=np.ones(len(data)) / len(data))
    ax = plt.gca()
    ax.yaxis.set_major_formatter(PercentFormatter(1))
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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()
    return 1

exec_context = r"""
import numpy as np
import matplotlib.pyplot as plt
data = [1000, 1000, 5000, 3000, 4000, 16000, 2000]
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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 plot
# Show marker on the line plot. Make the marker have a 0.5 transparency but keep the lines solid.
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    (l,) = plt.plot(x, y, "o-", lw=10, markersize=30)
    l.set_markerfacecolor((1, 1, 0, 0.5))
    l.set_color("blue")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        lines = ax.get_lines()
        assert len(lines) == 1
        assert lines[0].get_markerfacecolor()
        assert not isinstance(lines[0].get_markerfacecolor(), str)
        assert lines[0].get_markerfacecolor()[-1] == 0.5
        assert isinstance(lines[0].get_color(), str) or lines[0].get_color()[-1] == 1
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    a = np.arange(10)
    z = np.arange(10)
    fig, axs = plt.subplots(1, 2)
    axs[0].plot(x, y, label="y")
    axs[1].plot(z, a, label="a")
    plt.figlegend(["y", "a"])
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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
    return 1

exec_context = r"""
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)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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 2 subplots.
# In the first subplot, plot a seaborn regression plot of "bill_depth_mm" over "bill_length_mm"
# In the second subplot, plot a seaborn regression plot of "flipper_length_mm" over "bill_length_mm"
# Do not share y axix for the subplots
# SOLUTION START

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

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    df = sns.load_dataset("penguins")[
        ["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"]
    ]
    f, ax = plt.subplots(1, 2, figsize=(12, 6))
    sns.regplot(x="bill_length_mm", y="bill_depth_mm", data=df, ax=ax[0])
    sns.regplot(x="bill_length_mm", y="flipper_length_mm", data=df, ax=ax[1])
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        f = plt.gcf()
        assert len(f.axes) == 2
        assert len(f.axes[0]._shared_axes["x"].get_siblings(f.axes[0])) == 1
        for ax in f.axes:
            assert len(ax.collections) == 2
            assert len(ax.get_lines()) == 1
            assert ax.get_xlabel() == "bill_length_mm"
    return 1

exec_context = r"""
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"]
]
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    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)
    a = ax.get_xticks().tolist()
    a[1] = "second"
    ax.set_xticklabels(a)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert ax.xaxis.get_ticklabels()[1]._text == "second"
        assert ax.xaxis.get_ticklabels()[0]._text == "1"
    return 1

exec_context = r"""
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)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(y, x, label=r"$\lambda$")
    plt.legend()
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert ax.get_legend().get_texts()[0].get_text() == "$\\lambda$"
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

x = np.arange(10)
y = np.arange(10)
plt.plot(y, x)
plt.xticks(range(0, 10, 2))

# Add extra ticks [2.1, 3, 7.6] to existing xticks
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(y, x)
    plt.xticks(range(0, 10, 2))
    plt.xticks(list(plt.xticks()[0]) + [2.1, 3, 7.6])
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        plt.savefig("tempfig.png")
        all_ticks = [ax.get_loc() for ax in ax.xaxis.get_major_ticks()]
        assert len(all_ticks) == 8
        for i in [2.1, 3.0, 7.6]:
            assert i in all_ticks
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
plt.plot(y, x)
plt.xticks(range(0, 10, 2))
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

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

# Rotate the xticklabels to -60 degree. Set the xticks horizontal alignment to left.
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(2010, 2020)
    y = np.arange(10)
    plt.plot(x, y)
    plt.xticks(rotation=-60)
    plt.xticks(ha="left")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        for l in ax.get_xticklabels():
            assert l._horizontalalignment == "left"
            assert l._rotation == 300
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(2010, 2020)
y = np.arange(10)
plt.plot(x, y)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

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

# Rotate the yticklabels to -60 degree. Set the xticks vertical alignment to top.
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(2010, 2020)
    y = np.arange(10)
    plt.plot(x, y)
    plt.yticks(rotation=-60)
    plt.yticks(va="top")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        for l in ax.get_yticklabels():
            assert l._verticalalignment == "top"
            assert l._rotation == 300
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(2010, 2020)
y = np.arange(10)
plt.plot(x, y)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


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

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

# Set the transparency of xtick labels to be 0.5
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(2010, 2020)
    y = np.arange(10)
    plt.plot(x, y)
    plt.yticks(alpha=0.5)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        for l in ax.get_yticklabels():
            assert l._alpha == 0.5
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(2010, 2020)
y = np.arange(10)
plt.plot(x, y)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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 xtick but use greater than zero margin for the yaxis
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(x, y)
    plt.margins(x=0)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert ax.margins()[0] == 0
        assert ax.margins()[1] > 0
        assert ax.get_ylim()[0] < 0
    return 1

exec_context = r"""
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)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(x, y)
    plt.margins(y=0)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert ax.margins()[0] > 0
        assert ax.margins()[1] == 0
        assert ax.get_xlim()[0] < 0
    return 1

exec_context = r"""
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)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    fig = plt.figure(constrained_layout=True)
    axs = fig.subplots(1, 2)
    for ax in axs.flat:
        ax.plot(x, y)
    fig.suptitle("Figure")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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() == ""
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    values = [[1, 2], [3, 4]]
    df = pd.DataFrame(
        values, columns=["Type A", "Type B"], index=["Index 1", "Index 2"]
    )
    df.plot()
    plt.xlabel("X")
    plt.ylabel("Y")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.get_lines()) == 2
        assert ax.xaxis.label._text == "X"
        assert ax.yaxis.label._text == "Y"
    return 1

exec_context = r"""
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"])
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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 vertical line hatch for the marker and make the hatch dense
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.scatter(x, y, hatch="||||")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert ax.collections[0].get_hatch() is not None
        assert "|" in ax.collections[0].get_hatch()[0]
        assert len(ax.collections[0].get_hatch()) > 1
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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 remove the edge of the marker
# Use vertical line hatch for the marker
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.scatter(x, y, linewidth=0, hatch="|")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        lw_flag = True
        for l in ax.collections[0].get_linewidth():
            if l != 0:
                lw_flag = False
        assert lw_flag
        assert ax.collections[0].get_hatch() is not None
        assert "|" in ax.collections[0].get_hatch()[0]
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.scatter(x, y, hatch="*")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert ax.collections[0].get_hatch() is not None
        assert "*" in ax.collections[0].get_hatch()[0]
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.scatter(x, y, hatch="*|", s=500)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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()
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import matplotlib.pyplot as plt
import numpy as np

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

# Set xlim and ylim to be between 0 and 10
# Plot a heatmap of data in the rectangle where right is 5, left is 1, bottom is 1, and top is 4.
# SOLUTION START

import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
import matplotlib

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    data = np.random.random((10, 10))
    plt.xlim(0, 10)
    plt.ylim(0, 10)
    plt.imshow(data, extent=[1, 5, 1, 4])
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        for c in plt.gca().get_children():
            if isinstance(c, matplotlib.image.AxesImage):
                break
        assert c.get_extent() == [1, 5, 1, 4]
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
import numpy as np
data = np.random.random((10, 10))
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0.1, 2 * np.pi, 41)
y = np.exp(np.sin(x))

# make a stem plot of y over x and set the orientation to be horizontal
# SOLUTION START

import matplotlib.pyplot as plt
import numpy as np
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.linspace(0.1, 2 * np.pi, 41)
    y = np.exp(np.sin(x))
    plt.stem(x, y, orientation="horizontal")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.collections) == 1
        for seg in ax.collections[0].get_segments():
            assert seg[0][0] == 0
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0.1, 2 * np.pi, 41)
y = np.exp(np.sin(x))
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import matplotlib.pyplot as plt

d = {"a": 4, "b": 5, "c": 7}
c = {"a": "red", "c": "green", "b": "blue"}

# Make a bar plot using data in `d`. Use the keys as x axis labels and the values as the bar heights.
# Color each bar in the plot by looking up the color in colors
# SOLUTION START

import matplotlib.pyplot as plt
from PIL import Image
import numpy as np
import matplotlib

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    d = {"a": 4, "b": 5, "c": 7}
    c = {"a": "red", "c": "green", "b": "blue"}
    colors = []
    for k in d:
        colors.append(c[k])
    plt.bar(range(len(d)), d.values(), color=colors)
    plt.xticks(range(len(d)), d.keys())
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        plt.show()
        count = 0
        x_to_color = dict()
        for rec in ax.get_children():
            if isinstance(rec, matplotlib.patches.Rectangle):
                count += 1
                x_to_color[rec.get_x() + rec.get_width() / 2] = rec.get_facecolor()
        label_to_x = dict()
        for label in ax.get_xticklabels():
            label_to_x[label._text] = label._x
        assert (
            x_to_color[label_to_x["a"]] == (1.0, 0.0, 0.0, 1.0)
            or x_to_color[label_to_x["a"]] == "red"
        )
        assert (
            x_to_color[label_to_x["b"]] == (0.0, 0.0, 1.0, 1.0)
            or x_to_color[label_to_x["a"]] == "blue"
        )
        assert (
            x_to_color[label_to_x["c"]] == (0.0, 0.5019607843137255, 0.0, 1.0)
            or x_to_color[label_to_x["a"]] == "green"
        )
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
d = {"a": 4, "b": 5, "c": 7}
c = {"a": "red", "c": "green", "b": "blue"}
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import matplotlib.pyplot as plt

# Make a solid vertical line at x=3 and label it "cutoff". Show legend of this plot.
# SOLUTION START

import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    plt.axvline(x=3, label="cutoff")
    plt.legend()
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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"
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import matplotlib.pyplot as plt

labels = ["a", "b"]
height = [3, 4]

# Use polar projection for the figure and make a bar plot with labels in `labels` and bar height in `height`
# SOLUTION START

import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    labels = ["a", "b"]
    height = [3, 4]
    fig, ax = plt.subplots(subplot_kw={"projection": "polar"})
    plt.bar(labels, height)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert ax.name == "polar"
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
labels = ["a", "b"]
height = [3, 4]
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import matplotlib.pyplot as plt
from PIL import Image
import numpy as np
import matplotlib

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    l = ["a", "b", "c"]
    data = [225, 90, 50]
    plt.pie(data, labels=l, wedgeprops=dict(width=0.4))
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    l = ["a", "b", "c"]
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
l = ["a", "b", "c"]
data = [225, 90, 50]
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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 show blue dashed grid lines
# SOLUTION START

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(y, x)
    plt.grid(color="blue", linestyle="dashed")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert ax.xaxis._major_tick_kw["gridOn"]
        assert "grid_color" in ax.xaxis._major_tick_kw
        assert ax.xaxis._major_tick_kw["grid_color"] in ["blue", "b"]
        assert "grid_linestyle" in ax.xaxis._major_tick_kw
        assert ax.xaxis._major_tick_kw["grid_linestyle"] in ["dashed", "--", "-.", ":"]
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(y, x)
    plt.minorticks_on()
    plt.grid(color="gray", linestyle="dashed", which="minor")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import matplotlib.pyplot as plt

labels = ["Walking", "Talking", "Sleeping", "Working"]
sizes = [23, 45, 12, 20]
colors = ["red", "blue", "green", "yellow"]

# Make a pie chart with data in `sizes` and use `labels` as the pie labels and `colors` as the pie color.
# Bold the pie labels
# SOLUTION START

import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    labels = ["Walking", "Talking", "Sleeping", "Working"]
    sizes = [23, 45, 12, 20]
    colors = ["red", "blue", "green", "yellow"]
    plt.pie(sizes, colors=colors, labels=labels, textprops={"weight": "bold"})
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.texts) == 4
        for t in ax.texts:
            assert "bold" in t.get_fontweight()
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
labels = ["Walking", "Talking", "Sleeping", "Working"]
sizes = [23, 45, 12, 20]
colors = ["red", "blue", "green", "yellow"]
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
import matplotlib.pyplot as plt

labels = ["Walking", "Talking", "Sleeping", "Working"]
sizes = [23, 45, 12, 20]
colors = ["red", "blue", "green", "yellow"]

# Make a pie chart with data in `sizes` and use `labels` as the pie labels and `colors` as the pie color.
# Bold the pie labels
# SOLUTION START

import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    labels = ["Walking", "Talking", "Sleeping", "Working"]
    sizes = [23, 45, 12, 20]
    colors = ["red", "blue", "green", "yellow"]
    plt.pie(sizes, colors=colors, labels=labels, textprops={"weight": "bold"})
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        assert len(ax.texts) == 4
        for t in ax.texts:
            assert "bold" in t.get_fontweight()
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
labels = ["Walking", "Talking", "Sleeping", "Working"]
sizes = [23, 45, 12, 20]
colors = ["red", "blue", "green", "yellow"]
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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 but use transparent marker with non-transparent edge
# SOLUTION START

plt.plot(
    x, y, "-o", ms=14, markerfacecolor="None", markeredgecolor="red", markeredgewidth=5
)

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from PIL import Image

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    x = np.arange(10)
    y = np.arange(10)
    plt.plot(
        x,
        y,
        "-o",
        ms=14,
        markerfacecolor="None",
        markeredgecolor="red",
        markeredgewidth=5,
    )
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        ax = plt.gca()
        line = ax.get_lines()[0]
        assert line.get_markerfacecolor().lower() == "none"
        assert line.get_markeredgecolor().lower() != "none"
        assert line.get_linewidth() > 0
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.arange(10)
y = np.arange(10)
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)


Prompt:
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

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

def skip_plt_cmds(l):
    return all(
        p not in l for p in ["plt.show()", "plt.clf()", "plt.close()", "savefig"]
    )

def generate_test_case(test_case_id):
    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")
    plt.axvline(55, color="green")
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    code_img = np.array(Image.open("output.png"))
    oracle_img = np.array(Image.open("ans.png"))
    sample_image_stat = code_img.shape == oracle_img.shape and np.allclose(
        code_img, oracle_img
    )
    if not sample_image_stat:
        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)
    return 1

exec_context = r"""
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")
[insert]
plt.savefig('output.png', bbox_inches ='tight')
result = None
"""

def test_execution(solution: str):
    solution = "\n".join(filter(skip_plt_cmds, solution.split("\n")))
    code = exec_context.replace("[insert]", solution)
    for i in range(1):
        test_input, expected_result = generate_test_case(i + 1)
        test_env = {"test_input": test_input}
        exec(code, test_env)
        assert exec_test(test_env["result"], expected_result)