python - 使用 Google Colaboratory 时图表不显示
问题描述
我正在尝试使用 numpy 和 matplotlib.pyplot 在 Google Colabratory 中绘制剪切力图,但它没有出现在输出部分。我的代码如下:
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')
如果有人可以提供帮助,我将不胜感激。
解决方案
我发现了问题!我没跑%matplotlib inline
就跑import matplotlib.pyplot as plt
。
推荐阅读
- android - ExoPlayer 初始化播放器已弃用
- javascript - 如何合并来自两个相同长度的不同数组的对象?
- react-native - 术语“gradlew”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称
- reactjs - 如何将 ArrayBuffer 转换为 blob,以便将其转换为 URL 以进行视频播放
- rust - 在 Bevy 中读取鼠标点击的位置
- tls1.3 - DNSSEC 是否允许 TLS 快捷方式?
- qt - qml 中的索引数组
- python-3.x - 比较python中具有不同数据集的两个csv文件
- python - 尝试在 python (Ubuntu 18.04) 中导入 cv2 时收到并导入错误
- reactjs - React Hooks,单击按钮或链接时打开文章内容