Untitled
unknown
plain_text
5 months ago
820 B
2
Indexable
import numpy as np import matplotlib.pyplot as plt # Define the range for x x = np.linspace(-10, 10, 400) # Define the lines (replace these with your actual equations) lines = { 'Line 1: y = 2x + 3': 2 * x + 3, # m > 0, b > 0 'Line 2: y = -1x + 1': -1 * x + 1, # m < 0, b > 0 'Line 3: y = 0.5x - 2': 0.5 * x - 2, # m > 0, b < 0 'Line 4: y = 3x + 1': 3 * x + 1 # m > 0, b > 0 } # Plot each line for label, y in lines.items(): plt.plot(x, y, label=label) # Add axes, grid, and legend plt.axhline(0, color='black', linewidth=0.5, ls='--') plt.axvline(0, color='black', linewidth=0.5, ls='--') plt.grid(color='gray', linestyle='--', linewidth=0.5) plt.title('Graph of Lines') plt.xlabel('x') plt.ylabel('y') plt.ylim(-10, 10) plt.xlim(-10, 10) plt.legend() plt.show()
Editor is loading...
Leave a Comment