Last active
August 26, 2023 06:36
-
-
Save nickumia/fa5506806313caaf125fac76c79631c8 to your computer and use it in GitHub Desktop.
Pyplot lines example
This file contains 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 | |
gui_env = ['Qt4Agg','WXAgg', 'TKAgg','GTKAgg'] | |
for gui in gui_env: | |
try: | |
print("testing", gui) | |
matplotlib.use(gui,warn=False, force=True) | |
from matplotlib import pyplot as plt | |
break | |
except: | |
continue | |
print("Using:",matplotlib.get_backend()) |
This file contains 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 | |
n = 10 | |
for pos in np.linspace(-n, 2*n, 3*n+1): | |
plt.vlines(pos, 0, n) | |
plt.hlines(pos, 0, n) | |
for pos in np.linspace(-n, 2*n, 3*n*10+1): | |
plt.axline((pos, 0), slope=1, color='k', transform=plt.gca().transAxes) | |
plt.axline((pos, 0), slope=-1, color='k', transform=plt.gca().transAxes) | |
plt.ylim([0, n]) | |
plt.xlim([0, n]) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment