I want to create a matplotlib scatter plot such that each time i run the code it…
- User
I want to create a matplotlib scatter plot such that each time i run the code it produces the chart with different style / customization. Make sure to maximize diversity. You will only encounter cases with one x,y series data.
Assistant
Here is code to generate a matplotlib scatter plot with random style/customization each time:
import matplotlib.pyplot as plt import random # Data x = [1,2,3,4,5] y = [2,4,1,5,3] # Select random marker markers = ['o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd'] marker = random.choice(markers) # Select random color colors = ['r', 'g', 'b', 'c', 'm', 'y', 'k'] color = random.choice(colors) # Randomize size size = random.randint(10, 100) # Random line style ls = random.choice(['-', '--', '-.', ':']) # Random alpha alpha = random.random() # Plot plt.scatter(x, y, marker=marker, color=color, s=size, alpha=alpha, linewidths=1.5, linestyle=ls) # Add title plt.title(f"Scatter Plot - {marker} {color} {size} {alpha}") # Show plot plt.show()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.