benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 700b7335-9faa-5659-ba02-532c746cfd14

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import matplotlib.pyplot as plt
from itertools import zip_longest


# Constants
COLORS = ['red', 'green', 'blue', 'yellow', 'purple']

def task_func(data, labels):
    """    
    Plot a list of data with different colors. If there are more data series than the predefined colors, 
    the function cycles through the colors. In case of even more series than colors + labels, 'black' is used.
    
    Parameters:
    data (list): A list of lists, each representing a series of data.
    labels (list): A list of labels for the data series.
    
    Returns:
    matplotlib.axes.Axes: The Axes object of the plot.
    
    Requirements:
    - matplotlib.pyplot
    - itertools.zip_longest
    - Predefined colors are ['red', 'green', 'blue', 'yellow', 'purple'].
    
    Example:
    >>> data = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7]]
    >>> labels = ['Series 1', 'Series 2', 'Series 3']
    >>> ax = task_func(data, labels)
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    """

instruct prompt

Plot a list of data with different colors. If there are more data series than the predefined colors, the function cycles through the colors. In case of even more series than colors + labels, 'black' is used.
The function should output with:
    matplotlib.axes.Axes: The Axes object of the plot.
You should write self-contained code starting with:

Code

import matplotlib.pyplot as plt
from itertools import zip_longest
# Constants
COLORS = ['red', 'green', 'blue', 'yellow', 'purple']
def task_func(data, labels):

code prompt

Code

import matplotlib.pyplot as plt
from itertools import zip_longest
# Constants
COLORS = ['red', 'green', 'blue', 'yellow', 'purple']
def task_func(data, labels):

entry point

task_func

libs

  • matplotlib
  • itertools

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import