Untitled
unknown
plain_text
5 months ago
1.7 kB
2
Indexable
import matplotlib.pyplot as plt import numpy as np # Create a figure fig, ax = plt.subplots(figsize=(8, 6)) # Set limits and labels ax.set_xlim(-3, 3) ax.set_ylim(-3, 3) ax.set_xlabel('Horizontal Axis') ax.set_ylabel('Vertical Axis') ax.axhline(0, color='black', lw=0.5) ax.axvline(0, color='black', lw=0.5) # Draw the cart (m1) cart_x = [-1, 1, 1, -1, -1] cart_y = [0, 0, 0.5, 0.5, 0] ax.fill(cart_x, cart_y, color='blue', label='Cart (m1)', alpha=0.5) # Draw the hanging mass (m2) mass_x = [-0.5, 0.5, 0.5, -0.5, -0.5] mass_y = [1, 1, 1.5, 1.5, 1] ax.fill(mass_x, mass_y, color='red', label='Hanging Mass (m2)', alpha=0.5) # Draw forces acting on the cart (m1) # Normal force (upward) ax.arrow(0, 0.5, 0, 0.5, head_width=0.1, head_length=0.1, fc='green', ec='green', label='Normal Force (F_N)') # Friction force (left) ax.arrow(0.5, 0.25, -0.5, 0, head_width=0.1, head_length=0.1, fc='orange', ec='orange', label='Friction Force (F_f)') # Tension force (right) ax.arrow(-1, 0.25, 0.5, 0, head_width=0.1, head_length=0.1, fc='purple', ec='purple', label='Tension (T)') # Draw forces acting on the hanging mass (m2) # Weight (downward) ax.arrow(0, 1.5, 0, -0.5, head_width=0.1, head_length=0.1, fc='red', ec='red', label='Weight (F_g2)') # Annotations ax.text(0.1, 1.75, 'F_g2', fontsize=12, color='red') ax.text(-1.1, 0.25, 'T', fontsize=12, color='purple') ax.text(0.6, 0.25, 'F_f', fontsize=12, color='orange') ax.text(0.1, 1, 'F_N', fontsize=12, color='green') # Add legend ax.legend() # Title plt.title('Free Body Diagram (FBD) of Atwood Machine') plt.grid(False) plt.axis('off') # Turn off the axis plt.show()
Editor is loading...
Leave a Comment