o3-2025-04-16· OpenAI
LMArena Human Preference 140K
python code to plot sin(x) in 0 to 2 pi
- User
python code to plot sin(x) in 0 to 2 pi
- Assistant
Sure thing! Here’s a minimal example using NumPy and Matplotlib to plot sin(x) from 0 to 2π:
import numpy as np import matplotlib.pyplot as plt # 1. Create an array of x values from 0 to 2π x = np.linspace(0, 2 * np.pi, 1000) # 1000 points for a smooth curve # 2. Compute sin(x) y = np.sin(x) # 3. Plot plt.figure(figsize=(8, 4)) plt.plot(x, y, label=r'$\sin(x)$', color='dodgerblue', linewidth=2) # 4. Add labels, title, grid, legend plt.title('Sine Wave: 0 to 2π') plt.xlabel('x (radians)') plt.ylabel('sin(x)') plt.grid(True, alpha=0.3) plt.legend(loc='upper right') # 5. Display plt.show()Run this in any Python environment with NumPy and Matplotlib installed (e.g., Jupyter Notebook, VS Code, or a plain Python script). If you don’t have the libraries yet, you can install them via pip:
pip install numpy matplotlib
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.