0

I'm trying to plot a shear force graph in Google Colabratory using numpy and matplotlib.pyplot, and it's not showing up in the output section. My code is as follows:

import matplotlib.pyplot as plt
import numpy as np

# Create the graphu
x = np.linspace(0, d_OA + d_AB + d_BC, 1000)
V_xy = np.zeros_like(x)
for idx, loc in enumerate(x):
    if loc < d_OA:
        V_xy[idx] = R_oy
    elif ((loc >= d_OA) and (loc < d_OA + d_AB)):
        V_xy[idx] = R_oy - T_A*np.sin(theta_A)
    elif ((loc >= d_OA + d_AB) and (loc < d_OA + d_AB + d_BC)):
        V_xy[idx] = R_oy - T_A*np.sin(theta_A) - W*np.sin(theta_B)
    else:
        V_xy[idx] = R_oy - T_A*np.sin(theta_A) - W*np.sin(theta_B) + R_cy
    V_xy[0] = 0

# Plot the graph
plt.plot(x, V_xy, '-')
plt.grid(True)
plt.xlabel('x / m')
plt.ylabel('Vxy / N')

If anyone can help out, I'd really appreciate it.

  • It shows the image in my colab notebook. However, try adding plt.show() at the end – Patricio Loncomilla May 21 '21 at 03:41
  • Thank you very much for the quick response, but for whatever reason that didn't work either. Is it possible that I could be missing a semicolon or something of the like somewhere? – jross8599 May 21 '21 at 04:28

1 Answers1

0

I found the issue! I was running without %matplotlib inline right after import matplotlib.pyplot as plt.