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

seaborn.set(style="ticks")

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

# make seaborn relation plot and color by the gender field of the dataframe df
# SOLUTION START

import numpy
import pandas
import matplotlib.pyplot as plt
import seaborn
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):
    seaborn.set(style="ticks")
    numpy.random.seed(0)
    N = 37
    _genders = ["Female", "Male", "Non-binary", "No Response"]
    df = pandas.DataFrame(
        {
            "Height (cm)": numpy.random.uniform(low=130, high=200, size=N),
            "Weight (kg)": numpy.random.uniform(low=30, high=100, size=N),
            "Gender": numpy.random.choice(_genders, size=N),
        }
    )
    seaborn.relplot(
        data=df, x="Weight (kg)", y="Height (cm)", hue="Gender", hue_order=_genders
    )
    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_colors = set()
        for c in ax.collections:
            colors = c.get_facecolor()
            for i in range(colors.shape[0]):
                all_colors.add(tuple(colors[i]))
        assert len(all_colors) == 4
        assert ax.get_xlabel() == "Weight (kg)"
        assert ax.get_ylabel() == "Height (cm)"
    return 1

exec_context = r"""
import numpy
import pandas
import matplotlib.pyplot as plt
import seaborn
seaborn.set(style="ticks")
numpy.random.seed(0)
N = 37
_genders = ["Female", "Male", "Non-binary", "No Response"]
df = pandas.DataFrame(
    {
        "Height (cm)": numpy.random.uniform(low=130, high=200, size=N),
        "Weight (kg)": numpy.random.uniform(low=30, high=100, size=N),
        "Gender": numpy.random.choice(_genders, size=N),
    }
)
[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

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

# draw a regular matplotlib style plot using seaborn
# 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):
    x = np.arange(10)
    y = 2 * np.random.rand(10)
    sns.lineplot(x=x, y=y)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    x, y = result
    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()
        l = ax.lines[0]
        xp, yp = l.get_xydata().T
        np.testing.assert_array_almost_equal(xp, x)
        np.testing.assert_array_almost_equal(yp, y)
    return 1

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

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 seaborn as sns
import matplotlib.pyplot as plt

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

# draw a line plot of x vs y using seaborn and pandas
# SOLUTION START

import numpy as np
import pandas as pd
import seaborn as sns
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.sin(x)
    df = pd.DataFrame({"x": x, "y": y})
    sns.lineplot(x="x", y="y", data=df)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    x, y = result
    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) == 1
        np.testing.assert_allclose(ax.lines[0].get_data()[0], x)
        np.testing.assert_allclose(ax.lines[0].get_data()[1], y)
    return 1

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

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.randn(10)
y = np.random.randn(10)

# in plt.plot(x, y), use a plus marker and give it a thickness of 7
# SOLUTION START

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.randn(10)
    y = np.random.randn(10)
    plt.plot(x, y, "+", mew=7, ms=20)
    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) == 1
        assert ax.lines[0].get_markeredgewidth() == 7
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.random.randn(10)
y = np.random.randn(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

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

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

# show legend and set the font to size 20
# SOLUTION START

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):
    x = np.linspace(0, 2 * np.pi, 10)
    y = np.cos(x)
    plt.plot(x, y, label="sin")
    plt.rcParams["legend.fontsize"] = 20
    plt.legend(title="xxx")
    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()
        l = ax.get_legend()
        assert l.get_texts()[0].get_fontsize() == 20
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.linspace(0, 2 * np.pi, 10)
y = np.cos(x)
plt.plot(x, y, label="sin")
[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

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

# set legend title to xyz and set the title font to size 20
# SOLUTION START

# plt.figure()
plt.plot(x, y, label="sin")
ax = plt.gca()
ax.legend(title="xyz", title_fontsize=20)

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):
    x = np.linspace(0, 2 * np.pi, 10)
    y = np.cos(x)
    plt.plot(x, y, label="sin")
    ax = plt.gca()
    ax.legend(title="xyz", title_fontsize=20)
    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()
        l = ax.get_legend()
        t = l.get_title()
        assert t.get_fontsize() == 20
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.linspace(0, 2 * np.pi, 10)
y = np.cos(x)
[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

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

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

# set the face color of the markers to have an alpha (transparency) of 0.2
# SOLUTION START

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):
    x = np.random.randn(10)
    y = np.random.randn(10)
    (l,) = plt.plot(range(10), "o-", lw=5, markersize=30)
    l.set_markerfacecolor((1, 1, 0, 0.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()
        l = ax.lines[0]
        assert l.get_markerfacecolor()[3] == 0.2
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.random.randn(10)
y = np.random.randn(10)
(l,) = plt.plot(range(10), "o-", lw=5, markersize=30)
[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

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

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

# make the border of the markers solid black
# SOLUTION START

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):
    x = np.random.randn(10)
    y = np.random.randn(10)
    (l,) = plt.plot(range(10), "o-", lw=5, markersize=30)
    l.set_markeredgecolor((0, 0, 0, 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:
        ax = plt.gca()
        l = ax.lines[0]
        assert l.get_markeredgecolor() == (0, 0, 0, 1)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.random.randn(10)
y = np.random.randn(10)
(l,) = plt.plot(range(10), "o-", lw=5, markersize=30)
[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

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

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

# set both line and marker colors to be solid red
# SOLUTION START

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):
    x = np.random.randn(10)
    y = np.random.randn(10)
    (l,) = plt.plot(range(10), "o-", lw=5, markersize=30)
    l.set_markeredgecolor((1, 0, 0, 1))
    l.set_color((1, 0, 0, 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:
        ax = plt.gca()
        l = ax.lines[0]
        assert l.get_markeredgecolor() == (1, 0, 0, 1)
        assert l.get_color() == (1, 0, 0, 1)
        assert l.get_markerfacecolor() == (1, 0, 0, 1)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.random.randn(10)
y = np.random.randn(10)
(l,) = plt.plot(range(10), "o-", lw=5, markersize=30)
[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

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

# rotate the x axis labels clockwise by 45 degrees
# 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):
    x = np.linspace(0, 2 * np.pi, 10)
    y = np.cos(x)
    plt.plot(x, y, label="sin")
    plt.xticks(rotation=45)
    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()
        x = ax.get_xaxis()
        labels = ax.get_xticklabels()
        for l in labels:
            assert l.get_rotation() == 45
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.linspace(0, 2 * np.pi, 10)
y = np.cos(x)
plt.plot(x, y, label="sin")
[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

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

# rotate the x axis labels counter clockwise by 45 degrees
# SOLUTION START

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):
    x = np.linspace(0, 2 * np.pi, 10)
    y = np.cos(x)
    plt.plot(x, y, label="sin")
    plt.xticks(rotation=-45)
    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()
        x = ax.get_xaxis()
        labels = ax.get_xticklabels()
        for l in labels:
            assert l.get_rotation() == 360 - 45
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.linspace(0, 2 * np.pi, 10)
y = np.cos(x)
plt.plot(x, y, label="sin")
[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

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

# put a x axis ticklabels at 0, 2, 4...
# 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):
    x = np.linspace(0, 2 * np.pi, 10)
    y = np.cos(x)
    plt.plot(x, y, label="sin")
    minx = x.min()
    maxx = x.max()
    plt.xticks(np.arange(minx, maxx, step=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()
        plt.show()
        x = ax.get_xaxis()
        ticks = ax.get_xticks()
        labels = ax.get_xticklabels()
        for t, l in zip(ticks, ax.get_xticklabels()):
            assert int(t) % 2 == 0
            assert l.get_text() == str(int(t))
        assert all(sorted(ticks) == ticks)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.linspace(0, 2 * np.pi, 10)
y = np.cos(x)
plt.plot(x, y, label="sin")
[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

x = np.random.randn(10)
y = np.random.randn(10)
sns.distplot(x, label="a", color="0.25")
sns.distplot(y, label="b", color="0.25")

# add legends
# SOLUTION START

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):
    x = np.random.randn(10)
    y = np.random.randn(10)
    sns.distplot(x, label="a", color="0.25")
    sns.distplot(y, label="b", color="0.25")
    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.legend_ is not None, "there should be a legend"
        assert ax.legend_._visible
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.random.randn(10)
y = np.random.randn(10)
sns.distplot(x, label="a", color="0.25")
sns.distplot(y, label="b", color="0.25")
[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

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

# color plot of the 2d array H
# SOLUTION START

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):
    H = np.random.randn(10, 10)
    plt.imshow(H, interpolation="none")
    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.images) == 1
    return 1

exec_context = r"""
import numpy as np
import matplotlib.pyplot as plt
H = np.random.randn(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 matplotlib.pyplot as plt

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

# show the 2d array H in black and white
# SOLUTION START

import numpy as np
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):
    H = np.random.randn(10, 10)
    plt.imshow(H, cmap="gray")
    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.images) == 1
        assert isinstance(ax.images[0].cmap, matplotlib.colors.LinearSegmentedColormap)
        assert ax.images[0].cmap.name == "gray"
    return 1

exec_context = r"""
import numpy as np
import matplotlib.pyplot as plt
H = np.random.randn(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
import seaborn as sns

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

# set xlabel as "X"
# put the x label at the right end of the x axis
# SOLUTION START

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):
    x = np.linspace(0, 2 * np.pi, 10)
    y = np.cos(x)
    plt.plot(x, y)
    ax = plt.gca()
    label = ax.set_xlabel("X", fontsize=9)
    ax.xaxis.set_label_coords(1, 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()
        label = ax.xaxis.get_label()
        assert label.get_text() == "X"
        assert label.get_position()[0] > 0.8
        assert label.get_position()[0] < 1.5
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.linspace(0, 2 * np.pi, 10)
y = np.cos(x)
[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("planets")
g = sns.boxplot(x="method", y="orbital_period", data=df)

# rotate the x axis labels by 90 degrees
# 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("planets")
    g = sns.boxplot(x="method", y="orbital_period", data=df)
    ax = plt.gca()
    ax.set_xticklabels(ax.get_xticklabels(), rotation=90)
    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()
        xaxis = ax.get_xaxis()
        ticklabels = xaxis.get_ticklabels()
        assert len(ticklabels) > 0
        for t in ticklabels:
            assert 90 == t.get_rotation()
    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("planets")
g = sns.boxplot(x="method", y="orbital_period", data=df)
[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

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

# fit a very long title myTitle into multiple lines
# SOLUTION START

# set title
# plt.title(myTitle, loc='center', wrap=True)
from textwrap import wrap

ax = plt.gca()
ax.set_title("\n".join(wrap(myTitle, 60)), loc="center", wrap=True)
# axes.set_title("\n".join(wrap(myTitle, 60)), loc='center', wrap=True)

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from textwrap import wrap
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):
    y = 2 * np.random.rand(10)
    x = np.arange(10)
    plt.plot(x, y)
    myTitle = (
        "Some really really long long long title I really really need - and just can't - just can't - make it "
        "any - simply any - shorter - at all."
    )
    ax = plt.gca()
    ax.set_title("\n".join(wrap(myTitle, 60)), loc="center", wrap=True)
    plt.savefig("ans.png", bbox_inches="tight")
    plt.close()
    return None, None

def exec_test(result, ans):
    myTitle = (
        "Some really really long long long title I really really need - and just can't - just can't - make it "
        "any - simply any - shorter - at all."
    )
    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:
        fg = plt.gcf()
        assert fg.get_size_inches()[0] < 8
        ax = plt.gca()
        assert ax.get_title().startswith(myTitle[:10])
        assert "\n" in ax.get_title()
        assert len(ax.get_title()) >= len(myTitle)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
y = 2 * np.random.rand(10)
x = np.arange(10)
plt.plot(x, y)
myTitle = "Some really really long long long title I really really need - and just can't - just can't - make it any - simply any - shorter - at all."
[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

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

# make the y axis go upside down
# 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):
    y = 2 * np.random.rand(10)
    x = np.arange(10)
    ax = plt.gca()
    ax.invert_yaxis()
    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_ylim()[0] > ax.get_ylim()[1]
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
y = 2 * np.random.rand(10)
x = 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

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

# put x ticks at 0 and 1.5 only
# 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):
    x = np.random.randn(10)
    y = x
    plt.scatter(x, y)
    ax = plt.gca()
    ax.set_xticks([0, 1.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()
        np.testing.assert_equal([0, 1.5], ax.get_xticks())
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.random.randn(10)
y = x
plt.scatter(x, y)
[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

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

# put y ticks at -1 and 1 only
# 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):
    x = np.random.randn(10)
    y = x
    plt.scatter(x, y)
    ax = plt.gca()
    ax.set_yticks([-1, 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:
        ax = plt.gca()
        np.testing.assert_equal([-1, 1], ax.get_yticks())
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.random.randn(10)
y = x
plt.scatter(x, y)
[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

import numpy as np
import matplotlib.pyplot as plt

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

# plot x, then y then z, but so that x covers y and y covers z
# 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):
    x = np.random.rand(10)
    y = np.random.rand(10)
    z = np.random.rand(10)
    plt.plot(x, zorder=10)
    plt.plot(y, zorder=5)
    plt.plot(z, zorder=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:
        ax = plt.gca()
        ls = ax.lines
        assert len(ls) == 3
        zorder = [i.zorder for i in ls]
        np.testing.assert_equal(zorder, sorted(zorder, reverse=True))
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
x = np.random.rand(10)
y = np.random.rand(10)
z = 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.random.randn(10)
y = np.random.randn(10)

# in a scatter plot of x, y, make the points have black borders and blue face
# SOLUTION START

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.randn(10)
    y = np.random.randn(10)
    plt.scatter(x, y, c="blue", edgecolors="black")
    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
        edgecolors = ax.collections[0].get_edgecolors()
        assert edgecolors.shape[0] == 1
        assert np.allclose(edgecolors[0], [0.0, 0.0, 0.0, 1.0])
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.random.randn(10)
y = np.random.randn(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

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

# make all axes ticks integers
# 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):
    y = 2 * np.random.rand(10)
    x = np.arange(10)
    plt.bar(x, y)
    plt.yticks(np.arange(0, np.max(y), step=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:
        ax = plt.gca()
        assert all(y == int(y) for y in ax.get_yticks())
        assert all(x == int(x) for x in ax.get_yticks())
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
y = 2 * np.random.rand(10)
x = 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

data = {
    "reports": [4, 24, 31, 2, 3],
    "coverage": [35050800, 54899767, 57890789, 62890798, 70897871],
}
df = pd.DataFrame(data)
sns.catplot(y="coverage", x="reports", kind="bar", data=df, label="Total")

# do not use scientific notation in the y axis ticks labels
# 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):
    data = {
        "reports": [4, 24, 31, 2, 3],
        "coverage": [35050800, 54899767, 57890789, 62890798, 70897871],
    }
    df = pd.DataFrame(data)
    sns.catplot(y="coverage", x="reports", kind="bar", data=df, label="Total")
    plt.ticklabel_format(style="plain", axis="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()
        plt.show()
        assert len(ax.get_yticklabels()) > 0
        for l in ax.get_yticklabels():
            if int(l.get_text()) > 0:
                assert int(l.get_text()) > 1000
            assert "e" not in l.get_text()
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
data = {
    "reports": [4, 24, 31, 2, 3],
    "coverage": [35050800, 54899767, 57890789, 62890798, 70897871],
}
df = pd.DataFrame(data)
sns.catplot(y="coverage", x="reports", kind="bar", data=df, label="Total")
[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

y = 2 * np.random.rand(10)
x = np.arange(10)
ax = sns.lineplot(x=x, y=y)

# How to plot a dashed line on seaborn lineplot?
# 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):
    y = 2 * np.random.rand(10)
    x = np.arange(10)
    ax = sns.lineplot(x=x, y=y)
    ax.lines[0].set_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()
        lines = ax.lines[0]
        assert lines.get_linestyle() in ["--", "dashed"]
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
y = 2 * np.random.rand(10)
x = np.arange(10)
ax = sns.lineplot(x=x, y=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
import seaborn as sns

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

# plot x vs y1 and x vs y2 in two subplots, sharing the x axis
# SOLUTION START

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):
    x = np.linspace(0, 2 * np.pi, 400)
    y1 = np.sin(x)
    y2 = np.cos(x)
    fig, (ax1, ax2) = plt.subplots(nrows=2, sharex=True)
    plt.subplots_adjust(hspace=0.0)
    ax1.grid()
    ax2.grid()
    ax1.plot(x, y1, color="r")
    ax2.plot(x, y2, color="b", linestyle="--")
    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()
        ax12 = fig.axes
        assert len(ax12) == 2
        ax1, ax2 = ax12
        x1 = ax1.get_xticks()
        x2 = ax2.get_xticks()
        np.testing.assert_equal(x1, x2)
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.linspace(0, 2 * np.pi, 400)
y1 = np.sin(x)
y2 = np.cos(x)
[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

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

# plot x vs y1 and x vs y2 in two subplots
# remove the frames from the subplots
# SOLUTION START

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):
    x = np.linspace(0, 2 * np.pi, 400)
    y1 = np.sin(x)
    y2 = np.cos(x)
    fig, (ax1, ax2) = plt.subplots(nrows=2, subplot_kw=dict(frameon=False))
    plt.subplots_adjust(hspace=0.0)
    ax1.grid()
    ax2.grid()
    ax1.plot(x, y1, color="r")
    ax2.plot(x, y2, color="b", linestyle="--")
    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()
        ax12 = fig.axes
        assert len(ax12) == 2
        ax1, ax2 = ax12
        assert not ax1.get_frame_on()
        assert not ax2.get_frame_on()
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.linspace(0, 2 * np.pi, 400)
y1 = np.sin(x)
y2 = np.cos(x)
[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

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

# remove x axis label
# SOLUTION START

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):
    x = np.arange(10)
    y = np.sin(x)
    df = pd.DataFrame({"x": x, "y": y})
    sns.lineplot(x="x", y="y", data=df)
    ax = plt.gca()
    ax.set(xlabel=None)
    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()
        lbl = ax.get_xlabel()
        assert lbl == ""
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.arange(10)
y = np.sin(x)
df = pd.DataFrame({"x": x, "y": y})
sns.lineplot(x="x", y="y", data=df)
[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

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

# remove x tick labels
# SOLUTION START

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):
    x = np.arange(10)
    y = np.sin(x)
    df = pd.DataFrame({"x": x, "y": y})
    sns.lineplot(x="x", y="y", data=df)
    ax = plt.gca()
    ax.set(xticklabels=[])
    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()
        lbl = ax.get_xticklabels()
        ticks = ax.get_xticks()
        for t, tk in zip(lbl, ticks):
            assert (
                t.get_position()[0] == tk
            ), "tick might not been set, so the default was used"
            assert t.get_text() == "", "the text should be non-empty"
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.arange(10)
y = np.sin(x)
df = pd.DataFrame({"x": x, "y": y})
sns.lineplot(x="x", y="y", data=df)
[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

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

# show xticks and vertical grid at x positions 3 and 4
# SOLUTION START

ax = plt.gca()
# ax.set_yticks([-1, 1])
ax.xaxis.set_ticks([3, 4])
ax.xaxis.grid(True)

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):
    x = np.arange(10)
    y = np.random.randn(10)
    plt.scatter(x, y)
    ax = plt.gca()
    ax.xaxis.set_ticks([3, 4])
    ax.xaxis.grid(True)
    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()
        np.testing.assert_equal([3, 4], ax.get_xticks())
        xlines = ax.get_xaxis()
        l = xlines.get_gridlines()[0]
        assert l.get_visible()
        ylines = ax.get_yaxis()
        l = ylines.get_gridlines()[0]
        assert not l.get_visible()
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.arange(10)
y = np.random.randn(10)
plt.scatter(x, y)
[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

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

# show yticks and horizontal grid at y positions 3 and 4
# 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):
    x = np.arange(10)
    y = np.random.randn(10)
    plt.scatter(x, y)
    ax = plt.gca()
    ax.yaxis.set_ticks([3, 4])
    ax.yaxis.grid(True)
    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()
        xlines = ax.get_xaxis()
        l = xlines.get_gridlines()[0]
        assert not l.get_visible()
        np.testing.assert_equal([3, 4], ax.get_yticks())
        ylines = ax.get_yaxis()
        l = ylines.get_gridlines()[0]
        assert l.get_visible()
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.arange(10)
y = np.random.randn(10)
plt.scatter(x, y)
[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

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

# show yticks and horizontal grid at y positions 3 and 4
# show xticks and vertical grid at x positions 1 and 2
# SOLUTION START

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):
    x = np.arange(10)
    y = np.random.randn(10)
    plt.scatter(x, y)
    ax = plt.gca()
    ax.yaxis.set_ticks([3, 4])
    ax.yaxis.grid(True)
    ax.xaxis.set_ticks([1, 2])
    ax.xaxis.grid(True)
    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()
        np.testing.assert_equal([3, 4], ax.get_yticks())
        np.testing.assert_equal([1, 2], ax.get_xticks())
        xlines = ax.get_xaxis()
        l = xlines.get_gridlines()[0]
        assert l.get_visible()
        ylines = ax.get_yaxis()
        l = ylines.get_gridlines()[0]
        assert l.get_visible()
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.arange(10)
y = np.random.randn(10)
plt.scatter(x, y)
[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

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

# show grids
# 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):
    x = np.arange(10)
    y = np.random.randn(10)
    plt.scatter(x, y)
    ax = plt.gca()
    ax.grid(True)
    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()
        xlines = ax.get_xaxis()
        l = xlines.get_gridlines()[0]
        assert l.get_visible()
        ylines = ax.get_yaxis()
        l = ylines.get_gridlines()[0]
        assert l.get_visible()
        assert len(ax.lines) == 0
        assert len(ax.collections) == 1
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = np.arange(10)
y = np.random.randn(10)
plt.scatter(x, y)
[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

x = 10 * np.random.randn(10)
y = x
plt.plot(x, y, label="x-y")

# put legend in the lower right
# 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):
    x = 10 * np.random.randn(10)
    y = x
    plt.plot(x, y, label="x-y")
    plt.legend(loc="lower right")
    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() is not None
        assert ax.get_legend()._get_loc() == 4
    return 1

exec_context = r"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
x = 10 * np.random.randn(10)
y = x
plt.plot(x, y, label="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 matplotlib.pyplot as plt

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

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

plt.show()
plt.clf()

# Copy the previous plot but adjust the subplot padding to have enough space to display axis labels
# SOLUTION START

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):
    fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(8, 6))
    axes = axes.flatten()
    for ax in axes:
        ax.set_ylabel(r"$\ln\left(\frac{x_a-x_b}{x_a-x_c}\right)$")
        ax.set_xlabel(r"$\ln\left(\frac{x_a-x_d}{x_a-x_e}\right)$")
    plt.show()
    plt.clf()
    fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(8, 6))
    axes = axes.flatten()
    for ax in axes:
        ax.set_ylabel(r"$\ln\left(\frac{x_a-x_b}{x_a-x_c}\right)$")
        ax.set_xlabel(r"$\ln\left(\frac{x_a-x_d}{x_a-x_e}\right)$")
    plt.tight_layout()
    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 tuple(f.get_size_inches()) == (8, 6)
        assert f.subplotpars.hspace > 0.2
        assert f.subplotpars.wspace > 0.2
        assert len(f.axes) == 4
        for ax in f.axes:
            assert (
                ax.xaxis.get_label().get_text()
                == "$\\ln\\left(\\frac{x_a-x_d}{x_a-x_e}\\right)$"
            )
            assert (
                ax.yaxis.get_label().get_text()
                == "$\\ln\\left(\\frac{x_a-x_b}{x_a-x_c}\\right)$"
            )
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(8, 6))
axes = axes.flatten()
for ax in axes:
    ax.set_ylabel(r"$\ln\left(\frac{x_a-x_b}{x_a-x_c}\right)$")
    ax.set_xlabel(r"$\ln\left(\frac{x_a-x_d}{x_a-x_e}\right)$")
plt.show()
plt.clf()
[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, 20)
z = np.arange(10)

import matplotlib.pyplot as plt

plt.plot(x, y)
plt.plot(x, z)

# Give names to the lines in the above plot 'Y' and 'Z' and show them in a legend
# 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, 20)
    z = np.arange(10)
    plt.plot(x, y)
    plt.plot(x, z)
    plt.plot(x, y, label="Y")
    plt.plot(x, z, label="Z")
    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 tuple([t._text for t in ax.get_legend().get_texts()]) == ("Y", "Z")
    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, 20)
z = np.arange(10)
import matplotlib.pyplot as plt
plt.plot(x, y)
plt.plot(x, z)
[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

column_labels = list("ABCD")
row_labels = list("WXYZ")
data = np.random.rand(4, 4)
fig, ax = plt.subplots()
heatmap = ax.pcolor(data, cmap=plt.cm.Blues)

# Move the x-axis of this heatmap to the top of the plot
# 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):
    column_labels = list("ABCD")
    row_labels = list("WXYZ")
    data = np.random.rand(4, 4)
    fig, ax = plt.subplots()
    heatmap = ax.pcolor(data, cmap=plt.cm.Blues)
    ax.xaxis.tick_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()
        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"]
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
import numpy as np
column_labels = list("ABCD")
row_labels = list("WXYZ")
data = np.random.rand(4, 4)
fig, ax = plt.subplots()
heatmap = ax.pcolor(data, cmap=plt.cm.Blues)
[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
# Label the x-axis as "X"
# Set the space between the x-axis label and the x-axis to be 20
# 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.xlabel("X", labelpad=20)
    plt.tight_layout()
    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.labelpad == 20
        assert ax.get_xlabel() == "X"
    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
# do not show xticks for the plot
# 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.tick_params(
        axis="x",  # changes apply to the x-axis
        which="both",  # both major and minor ticks are affected
        bottom=False,  # ticks along the bottom edge are off
        top=False,  # ticks along the top edge are off
        labelbottom=False,
    )  # labels along the bottom edge are off
    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()
        label_off = not any(ax.xaxis._major_tick_kw.values())
        axis_off = not ax.axison
        no_ticks = len(ax.get_xticks()) == 0
        assert any([label_off, axis_off, no_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)
[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
# move the y axis ticks to the right
# 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 = plt.figure()
    ax = f.add_subplot(111)
    ax.plot(x, y)
    ax.yaxis.tick_right()
    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.yaxis.get_ticks_position() == "right"
        assert ax.yaxis._major_tick_kw["tick2On"]
        assert not ax.yaxis._major_tick_kw["tick1On"]
    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 and label y axis "Y"
# Show y axis ticks on the left and y axis label on the right
# 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.ylabel("y")
    ax = plt.gca()
    ax.yaxis.set_label_position("right")
    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.yaxis.get_label_position() == "right"
        assert not ax.yaxis._major_tick_kw["tick2On"]
        assert ax.yaxis._major_tick_kw["tick1On"]
    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, pandas as pd
import seaborn as sns

tips = sns.load_dataset("tips")

# Make a seaborn joint regression plot (kind='reg') of 'total_bill' and 'tip' in the tips dataframe
# change the line and scatter plot color to green but keep the distribution plot in blue
# SOLUTION START

import matplotlib.pyplot as plt
import numpy as np, pandas as pd
import seaborn as sns
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):
    tips = sns.load_dataset("tips")
    sns.jointplot(
        x="total_bill", y="tip", data=tips, kind="reg", joint_kws={"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:
        f = plt.gcf()
        assert len(f.axes) == 3
        assert len(f.axes[0].get_lines()) == 1
        assert f.axes[0].get_lines()[0]._color in ["green", "g", "#008000"]
        assert f.axes[0].collections[0].get_facecolor()[0][2] == 0
        for p in f.axes[1].patches:
            assert p.get_facecolor()[0] != 0
            assert p.get_facecolor()[2] != 0
        for p in f.axes[2].patches:
            assert p.get_facecolor()[0] != 0
            assert p.get_facecolor()[2] != 0
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
import numpy as np, pandas as pd
import seaborn as sns
tips = sns.load_dataset("tips")
[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, pandas as pd
import seaborn as sns

tips = sns.load_dataset("tips")

# Make a seaborn joint regression plot (kind='reg') of 'total_bill' and 'tip' in the tips dataframe
# change the line color in the regression to green but keep the histograms in blue
# SOLUTION START

import matplotlib.pyplot as plt
import numpy as np, pandas as pd
import seaborn as sns
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):
    tips = sns.load_dataset("tips")
    sns.jointplot(
        x="total_bill", y="tip", data=tips, kind="reg", line_kws={"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:
        f = plt.gcf()
        assert len(f.axes) == 3
        assert len(f.axes[0].get_lines()) == 1
        assert f.axes[0].get_xlabel() == "total_bill"
        assert f.axes[0].get_ylabel() == "tip"
        assert f.axes[0].get_lines()[0]._color in ["green", "g", "#008000"]
        for p in f.axes[1].patches:
            assert p.get_facecolor()[0] != 0
            assert p.get_facecolor()[2] != 0
        for p in f.axes[2].patches:
            assert p.get_facecolor()[0] != 0
            assert p.get_facecolor()[2] != 0
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
import numpy as np, pandas as pd
import seaborn as sns
tips = sns.load_dataset("tips")
[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, pandas as pd
import seaborn as sns

tips = sns.load_dataset("tips")

# Make a seaborn joint regression plot (kind='reg') of 'total_bill' and 'tip' in the tips dataframe
# do not use scatterplot for the joint plot
# SOLUTION START

import matplotlib.pyplot as plt
import numpy as np, pandas as pd
import seaborn as sns
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):
    tips = sns.load_dataset("tips")
    sns.jointplot(
        x="total_bill", y="tip", data=tips, kind="reg", joint_kws={"scatter": False}
    )
    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) == 3
        assert len(f.axes[0].get_lines()) == 1
        assert len(f.axes[0].collections) == 1
        assert f.axes[0].get_xlabel() == "total_bill"
        assert f.axes[0].get_ylabel() == "tip"
    return 1

exec_context = r"""
import matplotlib.pyplot as plt
import numpy as np, pandas as pd
import seaborn as sns
tips = sns.load_dataset("tips")
[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
import matplotlib.pyplot as plt
import pandas as pd

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

# For data in df, make a bar plot of s1 and s1 and use celltype as the xlabel
# Make the x-axis tick labels horizontal
# SOLUTION START

import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
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):
    df = pd.DataFrame(
        {
            "celltype": ["foo", "bar", "qux", "woz"],
            "s1": [5, 9, 1, 7],
            "s2": [12, 90, 13, 87],
        }
    )
    df = df[["celltype", "s1", "s2"]]
    df.set_index(["celltype"], inplace=True)
    df.plot(kind="bar", alpha=0.75, rot=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()
        plt.show()
        assert len(ax.patches) > 0
        assert len(ax.xaxis.get_ticklabels()) > 0
        for t in ax.xaxis.get_ticklabels():
            assert t._rotation == 0
        all_ticklabels = [t.get_text() for t in ax.xaxis.get_ticklabels()]
        for cell in ["foo", "bar", "qux", "woz"]:
            assert cell in all_ticklabels
    return 1

exec_context = r"""
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame(
    {
        "celltype": ["foo", "bar", "qux", "woz"],
        "s1": [5, 9, 1, 7],
        "s2": [12, 90, 13, 87],
    }
)
[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
import matplotlib.pyplot as plt
import pandas as pd

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

# For data in df, make a bar plot of s1 and s1 and use celltype as the xlabel
# Make the x-axis tick labels rotate 45 degrees
# SOLUTION START

import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
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):
    df = pd.DataFrame(
        {
            "celltype": ["foo", "bar", "qux", "woz"],
            "s1": [5, 9, 1, 7],
            "s2": [12, 90, 13, 87],
        }
    )
    df = df[["celltype", "s1", "s2"]]
    df.set_index(["celltype"], inplace=True)
    df.plot(kind="bar", alpha=0.75, rot=45)
    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.patches) > 0
        assert len(ax.xaxis.get_ticklabels()) > 0
        for t in ax.xaxis.get_ticklabels():
            assert t._rotation == 45
        all_ticklabels = [t.get_text() for t in ax.xaxis.get_ticklabels()]
        for cell in ["foo", "bar", "qux", "woz"]:
            assert cell in all_ticklabels
    return 1

exec_context = r"""
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame(
    {
        "celltype": ["foo", "bar", "qux", "woz"],
        "s1": [5, 9, 1, 7],
        "s2": [12, 90, 13, 87],
    }
)
[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 label the x axis as "X"
# Make both the x axis ticks and the axis label red
# 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()
    ax = fig.add_subplot(111)
    ax.plot(x, y)
    ax.set_xlabel("X", c="red")
    ax.xaxis.label.set_color("red")
    ax.tick_params(axis="x", colors="red")
    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.xaxis.label._color in ["red", "r"] or ax.xaxis.label._color == (
            1.0,
            0.0,
            0.0,
            1.0,
        )
        assert ax.xaxis._major_tick_kw["color"] in [
            "red",
            "r",
        ] or ax.xaxis._major_tick_kw["color"] == (1.0, 0.0, 0.0, 1.0)
        assert ax.xaxis._major_tick_kw["labelcolor"] in [
            "red",
            "r",
        ] or ax.xaxis._major_tick_kw["color"] == (1.0, 0.0, 0.0, 1.0)
    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 and label the x axis as "X"
# Make the line of the x axis red
# 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()
    ax = fig.add_subplot(111)
    ax.plot(x, y)
    ax.set_xlabel("X")
    ax.spines["bottom"].set_color("red")
    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.spines["bottom"].get_edgecolor() == "red" or ax.spines[
            "bottom"
        ].get_edgecolor() == (1.0, 0.0, 0.0, 1.0)
        assert ax.spines["top"].get_edgecolor() != "red" and ax.spines[
            "top"
        ].get_edgecolor() != (1.0, 0.0, 0.0, 1.0)
        assert ax.spines["left"].get_edgecolor() != "red" and ax.spines[
            "left"
        ].get_edgecolor() != (1.0, 0.0, 0.0, 1.0)
        assert ax.spines["right"].get_edgecolor() != "red" and ax.spines[
            "right"
        ].get_edgecolor() != (1.0, 0.0, 0.0, 1.0)
        assert ax.xaxis.label._color != "red" and ax.xaxis.label._color != (
            1.0,
            0.0,
            0.0,
            1.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 with tick font size 10 and make the x tick labels vertical
# 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(fontsize=10, rotation=90)
    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_tick_label_size("x") == 10
        assert ax.xaxis.get_ticklabels()[0]._rotation in [90, 270, "vertical"]
    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

# draw vertical lines at [0.22058956, 0.33088437, 2.20589566]
# 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=0.22058956)
    plt.axvline(x=0.33088437)
    plt.axvline(x=2.20589566)
    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:
        data = [0.22058956, 0.33088437, 2.20589566]
        ax = plt.gca()
        assert len(ax.lines) == 3
        for l in ax.lines:
            assert l.get_xdata()[0] in data
    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)