id stringlengths 7 11 | category stringclasses 7
values | difficulty stringclasses 3
values | prompt stringlengths 48 214 | solution stringlengths 38 255 | input_data stringlengths 16 455 | test_cases stringlengths 41 295 |
|---|---|---|---|---|---|---|
line_001 | line_plots | easy | Using the provided x and y arrays, create a simple line plot. | fig, ax = plt.subplots()
ax.plot(x, y) | {"type": "arrays", "x": [1, 2, 3, 4, 5], "y": [2, 4, 6, 8, 10]} | [{"type": "line_count", "expected": 1}, {"type": "line_data", "line_index": 0, "expected_y": [2, 4, 6, 8, 10]}] |
line_002 | line_plots | easy | Using the provided x and y arrays, create a line plot with the title 'Sales Over Time'. | fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('Sales Over Time') | {"type": "arrays", "x": [1, 2, 3, 4], "y": [100, 150, 130, 180]} | [{"type": "line_count", "expected": 1}, {"type": "title", "expected": "Sales Over Time"}] |
line_003 | line_plots | easy | Using the provided x and y arrays, create a red line plot. | fig, ax = plt.subplots()
ax.plot(x, y, color='red') | {"type": "arrays", "x": [0, 1, 2, 3], "y": [0, 1, 4, 9]} | [{"type": "line_count", "expected": 1}, {"type": "line_color", "line_index": 0, "expected": "red"}] |
line_004 | line_plots | medium | Using the provided x, y1, and y2 arrays, create a plot with two lines. Plot y1 in blue and y2 in red. | fig, ax = plt.subplots()
ax.plot(x, y1, color='blue')
ax.plot(x, y2, color='red') | {"type": "multi_arrays", "x": [0, 1, 2, 3, 4], "y1": [0, 1, 4, 9, 16], "y2": [0, 2, 4, 6, 8]} | [{"type": "line_count", "expected": 2}, {"type": "line_color", "line_index": 0, "expected": "blue"}, {"type": "line_color", "line_index": 1, "expected": "red"}] |
line_005 | line_plots | medium | Using the provided x, y1, and y2 arrays, create a plot with two lines. Label y1 as 'quadratic' and y2 as 'linear'. Add a legend. | fig, ax = plt.subplots()
ax.plot(x, y1, label='quadratic')
ax.plot(x, y2, label='linear')
ax.legend() | {"type": "multi_arrays", "x": [0, 1, 2], "y1": [0, 1, 4], "y2": [0, 1, 2]} | [{"type": "line_count", "expected": 2}, {"type": "legend_exists", "expected": true}, {"type": "legend_labels", "expected": ["quadratic", "linear"]}] |
line_006 | line_plots | medium | Using the provided x and y arrays, create a line plot with circle markers ('o') and a dashed line style ('--'). | fig, ax = plt.subplots()
ax.plot(x, y, marker='o', linestyle='--') | {"type": "arrays", "x": [1, 2, 3, 4, 5], "y": [1, 3, 2, 4, 3]} | [{"type": "line_count", "expected": 1}, {"type": "line_marker", "line_index": 0, "expected": "o"}, {"type": "line_style", "line_index": 0, "expected": "--"}] |
line_007 | line_plots | hard | Using the provided x, y1, and y2 arrays, create a 2x1 subplot. Plot y1 in the top subplot and y2 in the bottom subplot. Add grid to both. | fig, (ax1, ax2) = plt.subplots(2, 1)
ax1.plot(x, y1)
ax1.grid(True)
ax2.plot(x, y2)
ax2.grid(True) | {"type": "multi_arrays", "x": [0, 1, 2, 3, 4], "y1": [0, 1, 4, 9, 16], "y2": [1, 2, 4, 8, 16]} | [{"type": "axes_count", "expected": 2}, {"type": "line_count", "ax_index": 0, "expected": 1}, {"type": "line_count", "ax_index": 1, "expected": 1}, {"type": "grid_enabled", "ax_index": 0, "expected": true}, {"type": "grid_enabled", "ax_index": 1, "expected": true}] |
line_008 | line_plots | hard | Using the provided x and y arrays, create a line plot with logarithmic scale on the y-axis. | fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_yscale('log') | {"type": "arrays", "x": [1, 2, 3, 4, 5], "y": [10, 100, 1000, 10000, 100000]} | [{"type": "line_count", "expected": 1}, {"type": "yscale", "expected": "log"}] |
scatter_001 | scatter_plots | easy | Using the provided x and y arrays, create a scatter plot. | fig, ax = plt.subplots()
ax.scatter(x, y) | {"type": "arrays", "x": [1, 2, 3, 4], "y": [1, 4, 9, 16]} | [{"type": "scatter_count", "expected": 4}, {"type": "scatter_offsets", "expected": [[1, 1], [2, 4], [3, 9], [4, 16]]}] |
scatter_002 | scatter_plots | easy | Using the provided x and y arrays, create a scatter plot with green markers. | fig, ax = plt.subplots()
ax.scatter(x, y, c='green') | {"type": "arrays", "x": [1, 2, 3, 4, 5], "y": [5, 4, 3, 2, 1]} | [{"type": "scatter_count", "expected": 5}, {"type": "scatter_facecolor", "collection_index": 0, "expected": "green"}] |
scatter_003 | scatter_plots | easy | Using the provided x and y arrays, create a scatter plot with marker size 100. | fig, ax = plt.subplots()
ax.scatter(x, y, s=100) | {"type": "arrays", "x": [1, 2, 3], "y": [1, 2, 3]} | [{"type": "scatter_count", "expected": 3}, {"type": "scatter_sizes", "collection_index": 0, "expected": 100}] |
scatter_004 | scatter_plots | medium | Using the provided x, y_a, and y_b arrays, create two scatter series. Plot y_a in red and y_b in blue. | fig, ax = plt.subplots()
ax.scatter(x, y_a, c='red')
ax.scatter(x, y_b, c='blue') | {"type": "multi_arrays", "x": [1, 2, 3], "y_a": [2, 3, 4], "y_b": [4, 5, 6]} | [{"type": "collection_count", "expected": 2}, {"type": "scatter_facecolor", "collection_index": 0, "expected": "red"}, {"type": "scatter_facecolor", "collection_index": 1, "expected": "blue"}] |
scatter_005 | scatter_plots | medium | Using the provided x, y_a, and y_b arrays, create two scatter series with alpha=0.5 for y_a and alpha=0.7 for y_b. Add a legend with labels 'A' and 'B'. | fig, ax = plt.subplots()
ax.scatter(x, y_a, alpha=0.5, label='A')
ax.scatter(x, y_b, alpha=0.7, label='B')
ax.legend() | {"type": "multi_arrays", "x": [1, 2, 3], "y_a": [2, 3, 4], "y_b": [4, 5, 6]} | [{"type": "collection_count", "expected": 2}, {"type": "scatter_alpha", "collection_index": 0, "expected": 0.5}, {"type": "scatter_alpha", "collection_index": 1, "expected": 0.7}, {"type": "legend_exists", "expected": true}] |
scatter_006 | scatter_plots | hard | Using the provided x, y, and sizes arrays, create a scatter plot where each point has a different size based on the sizes array. | fig, ax = plt.subplots()
ax.scatter(x, y, s=sizes) | {"type": "multi_arrays", "x": [1, 2, 3, 4, 5], "y": [1, 4, 9, 16, 25], "sizes": [20, 50, 100, 200, 400]} | [{"type": "scatter_count", "expected": 5}, {"type": "scatter_sizes_array", "collection_index": 0, "expected": [20, 50, 100, 200, 400]}] |
scatter_007 | scatter_plots | hard | Using the provided x, y, and colors arrays, create a scatter plot where point colors are determined by the colors array using the 'viridis' colormap. Add a colorbar. | fig, ax = plt.subplots()
sc = ax.scatter(x, y, c=colors, cmap='viridis')
plt.colorbar(sc) | {"type": "multi_arrays", "x": [1, 2, 3, 4, 5], "y": [1, 2, 3, 4, 5], "colors": [0, 25, 50, 75, 100]} | [{"type": "scatter_count", "expected": 5}, {"type": "colorbar_exists", "expected": true}] |
bar_001 | bar_charts | easy | Using the provided categories and heights arrays, create a bar chart. | fig, ax = plt.subplots()
ax.bar(categories, heights) | {"type": "bar_data", "categories": ["A", "B", "C"], "heights": [10, 20, 15]} | [{"type": "bar_count", "expected": 3}, {"type": "bar_heights", "expected": [10, 20, 15]}] |
bar_002 | bar_charts | easy | Using the provided categories and heights arrays, create a bar chart with orange bars. | fig, ax = plt.subplots()
ax.bar(categories, heights, color='orange') | {"type": "bar_data", "categories": ["X", "Y", "Z"], "heights": [5, 15, 10]} | [{"type": "bar_count", "expected": 3}, {"type": "bar_color", "expected": "orange"}] |
bar_003 | bar_charts | medium | Using the provided categories and widths arrays, create a horizontal bar chart. | fig, ax = plt.subplots()
ax.barh(categories, widths) | {"type": "bar_data", "categories": ["Product A", "Product B", "Product C"], "widths": [100, 150, 80]} | [{"type": "bar_count", "expected": 3}, {"type": "bar_widths", "expected": [100, 150, 80]}] |
bar_004 | bar_charts | medium | Using the provided categories, values_a, and values_b arrays, create a grouped bar chart. Place group A bars and group B bars side by side. Use width=0.35 and label them 'Group A' and 'Group B'. Add a legend. | import numpy as np
fig, ax = plt.subplots()
x = np.arange(len(categories))
width = 0.35
ax.bar(x - width/2, values_a, width, label='Group A')
ax.bar(x + width/2, values_b, width, label='Group B')
ax.set_xticks(x)
ax.set_xticklabels(categories)
ax.legend() | {"type": "grouped_bar_data", "categories": ["Q1", "Q2", "Q3"], "values_a": [20, 35, 30], "values_b": [25, 32, 34]} | [{"type": "bar_count", "expected": 6}, {"type": "legend_exists", "expected": true}] |
bar_005 | bar_charts | medium | Using the provided categories and heights arrays, create a bar chart with blue fill and black edge color with edge width of 2. | fig, ax = plt.subplots()
ax.bar(categories, heights, color='blue', edgecolor='black', linewidth=2) | {"type": "bar_data", "categories": ["Jan", "Feb", "Mar", "Apr"], "heights": [30, 45, 38, 50]} | [{"type": "bar_count", "expected": 4}, {"type": "bar_color", "expected": "blue"}, {"type": "bar_edgecolor", "expected": "black"}] |
bar_006 | bar_charts | hard | Using the provided categories, heights_a, and heights_b arrays, create a stacked bar chart. Plot heights_a in blue with label 'Product A', then stack heights_b on top in orange with label 'Product B'. Add a legend. | fig, ax = plt.subplots()
ax.bar(categories, heights_a, label='Product A', color='blue')
ax.bar(categories, heights_b, bottom=heights_a, label='Product B', color='orange')
ax.legend() | {"type": "stacked_bar_data", "categories": ["Q1", "Q2", "Q3"], "heights_a": [20, 25, 30], "heights_b": [15, 20, 25]} | [{"type": "bar_count", "expected": 6}, {"type": "legend_exists", "expected": true}, {"type": "legend_labels", "expected": ["Product A", "Product B"]}] |
bar_007 | bar_charts | hard | Using the provided categories, heights, and errors arrays, create a bar chart with error bars. | fig, ax = plt.subplots()
ax.bar(categories, heights, yerr=errors, capsize=5) | {"type": "bar_error_data", "categories": ["A", "B", "C", "D"], "heights": [25, 40, 30, 55], "errors": [2, 3, 2.5, 4]} | [{"type": "bar_count", "expected": 4}, {"type": "errorbar_exists", "expected": true}] |
bar_008 | bar_charts | hard | Using the provided categories and heights arrays, create a bar chart and add the height value as a text label on top of each bar. | fig, ax = plt.subplots()
bars = ax.bar(categories, heights)
for bar in bars:
height = bar.get_height()
ax.text(bar.get_x() + bar.get_width()/2., height, f'{height}', ha='center', va='bottom') | {"type": "bar_data", "categories": ["A", "B", "C"], "heights": [10, 25, 15]} | [{"type": "bar_count", "expected": 3}, {"type": "text_count", "expected": 3}] |
hist_001 | histograms | easy | Using the provided values array, create a histogram with default bins. | fig, ax = plt.subplots()
ax.hist(values) | {"type": "hist_data", "values": [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5]} | [{"type": "patch_count_gte", "expected": 3}] |
hist_002 | histograms | easy | Using the provided values array, create a histogram with exactly 5 bins. | fig, ax = plt.subplots()
ax.hist(values, bins=5) | {"type": "hist_data", "values": [1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5]} | [{"type": "hist_bin_count", "expected": 5}] |
hist_003 | histograms | easy | Using the provided values array, create a histogram with green bars. | fig, ax = plt.subplots()
ax.hist(values, color='green') | {"type": "hist_data", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]} | [{"type": "patch_count_gte", "expected": 3}, {"type": "hist_color", "expected": "green"}] |
hist_004 | histograms | medium | Using the provided values array, create a histogram with density=True (normalized so area sums to 1). | fig, ax = plt.subplots()
ax.hist(values, density=True) | {"type": "hist_data", "values": [1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5]} | [{"type": "hist_density", "expected": true}] |
hist_005 | histograms | medium | Using the provided values array, create a histogram with blue bars, black edges, and 10 bins. | fig, ax = plt.subplots()
ax.hist(values, bins=10, color='blue', edgecolor='black') | {"type": "hist_data", "values": [44, 55, 47, 50, 54, 38, 35, 35, 68, 58, 44, 35, 47, 38, 45, 53, 70, 49, 50, 48, 68, 34, 42, 56, 62, 33, 64, 53, 40, 46, 56, 41, 57, 66, 55, 56, 39, 43, 63, 59, 48, 55, 49, 60, 32, 40, 53, 65, 38, 51, 49, 54, 54, 46, 52, 67, 57, 39, 51, 42, 24, 46, 54, 34, 53, 56, 47, 38, 44, 42, 56, 46,... | [{"type": "hist_bin_count", "expected": 10}, {"type": "hist_color", "expected": "blue"}, {"type": "hist_edgecolor", "expected": "black"}] |
hist_006 | histograms | hard | Using the provided values_a and values_b arrays, create two overlapping histograms with alpha=0.5. Use 10 bins, label them 'Group A' and 'Group B', and add a legend. | fig, ax = plt.subplots()
ax.hist(values_a, bins=10, alpha=0.5, label='Group A')
ax.hist(values_b, bins=10, alpha=0.5, label='Group B')
ax.legend() | {"type": "multi_hist_data", "values_a": [43, 52, 46, 42, 37, 47, 42, 35, 42, 38, 40, 45, 41, 39, 42, 40, 37, 49, 42, 46, 43, 39, 32, 43, 29, 42, 43, 41, 36, 51, 44, 44, 36, 36, 39, 42, 43, 43, 42, 39, 35, 46, 38, 40, 39, 43, 45, 43, 37, 28], "values_b": [65, 51, 49, 48, 54, 52, 48, 58, 49, 52, 51, 43, 51, 43, 42, 44, 5... | [{"type": "legend_exists", "expected": true}, {"type": "legend_labels", "expected": ["Group A", "Group B"]}] |
hist_007 | histograms | hard | Using the provided values array, create a cumulative histogram (cumulative=True) with 20 bins. | fig, ax = plt.subplots()
ax.hist(values, bins=20, cumulative=True) | {"type": "hist_data", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, ... | [{"type": "hist_bin_count", "expected": 20}, {"type": "hist_cumulative", "expected": true}] |
box_001 | boxplots | medium | Using the provided data array, create a boxplot. | fig, ax = plt.subplots()
ax.boxplot(data) | {"type": "box_data", "data": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]} | [{"type": "boxplot_exists", "expected": true}, {"type": "boxplot_median", "expected": 5.5}] |
box_002 | boxplots | medium | Using the provided data_a, data_b, and data_c arrays, create three side-by-side boxplots. | fig, ax = plt.subplots()
ax.boxplot([data_a, data_b, data_c]) | {"type": "multi_box_data", "data_a": [1, 2, 3, 4, 5], "data_b": [3, 4, 5, 6, 7], "data_c": [5, 6, 7, 8, 9]} | [{"type": "boxplot_count", "expected": 3}] |
box_003 | boxplots | medium | Using the provided data_a and data_b arrays, create two boxplots with labels 'Control' and 'Treatment'. | fig, ax = plt.subplots()
ax.boxplot([data_a, data_b], labels=['Control', 'Treatment']) | {"type": "multi_box_data", "data_a": [10, 12, 14, 16, 18], "data_b": [20, 22, 24, 26, 28]} | [{"type": "boxplot_count", "expected": 2}, {"type": "xticklabels", "expected": ["Control", "Treatment"]}] |
box_004 | boxplots | hard | Using the provided data_a and data_b arrays, create two horizontal boxplots (vert=False). | fig, ax = plt.subplots()
ax.boxplot([data_a, data_b], vert=False) | {"type": "multi_box_data", "data_a": [15, 18, 20, 22, 25], "data_b": [30, 32, 35, 38, 40]} | [{"type": "boxplot_count", "expected": 2}, {"type": "boxplot_orientation", "expected": "horizontal"}] |
box_005 | boxplots | hard | Using the provided DataFrame df (with columns 'value' and 'group'), create a seaborn boxplot comparing the groups. | fig, ax = plt.subplots()
sns.boxplot(data=df, x='group', y='value', ax=ax) | {"type": "dataframe", "df": {"value": [10, 12, 14, 16, 18, 20, 22, 24, 26, 28], "group": ["A", "A", "A", "A", "A", "B", "B", "B", "B", "B"]}} | [{"type": "boxplot_count", "expected": 2}] |
box_006 | boxplots | hard | Using the provided data_a and data_b arrays, create a violin plot showing both distributions. | fig, ax = plt.subplots()
ax.violinplot([data_a, data_b]) | {"type": "multi_box_data", "data_a": [53, 59, 52, 49, 51, 41, 51, 52, 48, 53, 44, 40, 43, 46, 53, 52, 51, 48, 51, 46, 53, 42, 55, 51, 49, 58, 43, 49, 59, 51], "data_b": [72, 57, 52, 57, 53, 48, 60, 54, 63, 62, 53, 58, 74, 52, 60, 63, 56, 65, 66, 46, 57, 67, 54, 69, 60, 47, 61, 64, 57, 52]} | [{"type": "violin_count", "expected": 2}] |
text_001 | annotations | easy | Create an empty plot with title 'My Plot', x-label 'X Axis', and y-label 'Y Axis'. | fig, ax = plt.subplots()
ax.set_title('My Plot')
ax.set_xlabel('X Axis')
ax.set_ylabel('Y Axis') | {"type": "none"} | [{"type": "title", "expected": "My Plot"}, {"type": "xlabel", "expected": "X Axis"}, {"type": "ylabel", "expected": "Y Axis"}] |
text_002 | annotations | easy | Using the provided x and y arrays, create a line plot with title 'Temperature Over Time', x-label 'Day', and y-label 'Temperature (°C)'. | fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('Temperature Over Time')
ax.set_xlabel('Day')
ax.set_ylabel('Temperature (°C)') | {"type": "arrays", "x": [1, 2, 3, 4, 5], "y": [20, 22, 21, 23, 25]} | [{"type": "title", "expected": "Temperature Over Time"}, {"type": "xlabel", "expected": "Day"}, {"type": "ylabel", "expected": "Temperature (\u00b0C)"}] |
text_003 | annotations | medium | Using the provided x and y arrays, create a line plot. Add a text annotation 'Peak' at position (3, 9). | fig, ax = plt.subplots()
ax.plot(x, y)
ax.text(3, 9, 'Peak') | {"type": "arrays", "x": [1, 2, 3, 4, 5], "y": [1, 4, 9, 4, 1]} | [{"type": "line_count", "expected": 1}, {"type": "text_content", "expected": "Peak"}] |
text_004 | annotations | medium | Using the provided x and y arrays, create a line plot. Add an annotation 'Maximum' pointing to the point (4, 16) with an arrow from position (2, 12). | fig, ax = plt.subplots()
ax.plot(x, y)
ax.annotate('Maximum', xy=(4, 16), xytext=(2, 12), arrowprops=dict(arrowstyle='->')) | {"type": "arrays", "x": [0, 1, 2, 3, 4], "y": [0, 1, 4, 9, 16]} | [{"type": "line_count", "expected": 1}, {"type": "annotation_count", "expected": 1}, {"type": "annotation_text", "index": 0, "expected": "Maximum"}] |
text_005 | annotations | hard | Using the provided x and y arrays, create a line plot. Add annotations 'Start' at the first point and 'End' at the last point, both with arrows. | fig, ax = plt.subplots()
ax.plot(x, y)
ax.annotate('Start', xy=(0, 10), xytext=(0.5, 8), arrowprops=dict(arrowstyle='->'))
ax.annotate('End', xy=(4, 20), xytext=(3.5, 22), arrowprops=dict(arrowstyle='->')) | {"type": "arrays", "x": [0, 1, 2, 3, 4], "y": [10, 15, 12, 18, 20]} | [{"type": "annotation_count", "expected": 2}] |
text_006 | annotations | medium | Using the provided x and y arrays, create a line plot. Set x-axis limits to (0, 10) and y-axis limits to (0, 50). | fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_xlim(0, 10)
ax.set_ylim(0, 50) | {"type": "arrays", "x": [1, 2, 3, 4, 5], "y": [10, 20, 30, 40, 50]} | [{"type": "xlim", "expected": [0, 10]}, {"type": "ylim", "expected": [0, 50]}] |
text_007 | annotations | hard | Using the provided categories and heights arrays, create a bar chart. Set the x-tick labels to ['January', 'February', 'March'] with 45-degree rotation. | fig, ax = plt.subplots()
ax.bar(categories, heights)
ax.set_xticks(categories)
ax.set_xticklabels(['January', 'February', 'March'], rotation=45) | {"type": "bar_data", "categories": [0, 1, 2], "heights": [100, 150, 120]} | [{"type": "bar_count", "expected": 3}, {"type": "xticklabels", "expected": ["January", "February", "March"]}] |
layout_001 | layouts | medium | Using the provided line_data and scatter_x/scatter_y arrays, create a 1x2 subplot. Left: line plot of line_data. Right: scatter plot using scatter_x and scatter_y. | fig, (ax1, ax2) = plt.subplots(1, 2)
ax1.plot(line_data)
ax2.scatter(scatter_x, scatter_y) | {"type": "layout_data", "line_data": [1, 2, 3, 4], "scatter_x": [1, 2, 3], "scatter_y": [1, 2, 3]} | [{"type": "axes_count", "expected": 2}, {"type": "line_count", "ax_index": 0, "expected": 1}, {"type": "scatter_count", "ax_index": 1, "expected": 3}] |
layout_002 | layouts | medium | Using the provided y1 and y2 arrays, create a 2x1 subplot (2 rows, 1 column). Top: line plot of y1. Bottom: line plot of y2. | fig, (ax1, ax2) = plt.subplots(2, 1)
ax1.plot(y1)
ax2.plot(y2) | {"type": "multi_arrays", "y1": [1, 4, 9, 16], "y2": [1, 2, 3, 4]} | [{"type": "axes_count", "expected": 2}, {"type": "line_count", "ax_index": 0, "expected": 1}, {"type": "line_count", "ax_index": 1, "expected": 1}] |
layout_003 | layouts | medium | Using the provided x and y arrays, create a line plot with figure size (10, 6). | fig, ax = plt.subplots(figsize=(10, 6))
ax.plot(x, y) | {"type": "arrays", "x": [1, 2, 3, 4, 5], "y": [1, 4, 9, 16, 25]} | [{"type": "figure_size", "expected": [10, 6]}] |
layout_004 | layouts | hard | Create a 2x2 grid of subplots. In position (0,0) plot a line [1,2,3,4]. In (0,1) scatter points (1,1),(2,2),(3,3). In (1,0) create bars with heights [3,2,1]. In (1,1) create a histogram of [1,1,2,2,2,3]. | fig, axs = plt.subplots(2, 2)
axs[0, 0].plot(line_y)
axs[0, 1].scatter(scatter_x, scatter_y)
axs[1, 0].bar([0, 1, 2], bar_heights)
axs[1, 1].hist(hist_values) | {"type": "complex_layout", "line_y": [1, 2, 3, 4], "scatter_x": [1, 2, 3], "scatter_y": [1, 2, 3], "bar_heights": [3, 2, 1], "hist_values": [1, 1, 2, 2, 2, 3]} | [{"type": "axes_count", "expected": 4}, {"type": "line_count", "ax_index": 0, "expected": 1}, {"type": "scatter_count", "ax_index": 1, "expected": 3}, {"type": "bar_count", "ax_index": 2, "expected": 3}] |
layout_005 | layouts | hard | Using the provided y1 and y2 arrays, create a 2x1 subplot with shared x-axis (sharex=True). Plot y1 in top and y2 in bottom. | fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
ax1.plot(y1)
ax2.plot(y2) | {"type": "multi_arrays", "y1": [1, 4, 9, 16, 25], "y2": [25, 16, 9, 4, 1]} | [{"type": "axes_count", "expected": 2}, {"type": "shared_axis", "axis": "x", "expected": true}] |
layout_006 | layouts | hard | Using the provided x, y1, and y2 arrays, create a plot with two y-axes. Plot y1 on the left axis in blue and y2 on the right axis (using ax.twinx()) in red. | fig, ax1 = plt.subplots()
ax1.plot(x, y1, color='blue')
ax2 = ax1.twinx()
ax2.plot(x, y2, color='red') | {"type": "multi_arrays", "x": [1, 2, 3, 4, 5], "y1": [10, 20, 30, 40, 50], "y2": [1000, 2000, 1500, 2500, 3000]} | [{"type": "axes_count", "expected": 2}, {"type": "line_count", "ax_index": 0, "expected": 1}, {"type": "line_count", "ax_index": 1, "expected": 1}] |
layout_007 | layouts | hard | Create a 2x2 subplot. Add a unique title to each subplot: 'Plot 1', 'Plot 2', 'Plot 3', 'Plot 4'. Use plt.tight_layout() to prevent overlapping. | fig, axs = plt.subplots(2, 2)
axs[0, 0].set_title('Plot 1')
axs[0, 1].set_title('Plot 2')
axs[1, 0].set_title('Plot 3')
axs[1, 1].set_title('Plot 4')
plt.tight_layout() | {"type": "none"} | [{"type": "axes_count", "expected": 4}, {"type": "subplot_title", "ax_index": 0, "expected": "Plot 1"}, {"type": "subplot_title", "ax_index": 1, "expected": "Plot 2"}, {"type": "subplot_title", "ax_index": 2, "expected": "Plot 3"}, {"type": "subplot_title", "ax_index": 3, "expected": "Plot 4"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.