Created
December 23, 2021 15:46
-
-
Save ugo-nama-kun/dc6067fc4d371fd52dae796b1e790a8c to your computer and use it in GitHub Desktop.
Barplot + Angle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
x = np.linspace(0, 2, 10) | |
y = np.linspace(2, 0, 10) | |
err = 0.1 + np.random.rand(len(x)) * 0.3 | |
angle = np.random.rand(len(x)) * np.pi / 3 | |
plt.figure(figsize=(2, 2), dpi=300) | |
for i in range(len(x)): | |
dx = err[i] * np.cos(angle[i]) | |
dy = err[i] * np.sin(angle[i]) | |
plt.plot([x[i], x[i] + dx], [y[i], y[i] + dy], "k", linewidth=1) | |
plt.plot([x[i], x[i] - dx], [y[i], y[i] - dy], "k", linewidth=1) | |
plt.plot(x, y, "ok", markersize=5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result