Skip to content

Instantly share code, notes, and snippets.

@sabopy
Last active August 4, 2020 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sabopy/fe33f762e1e6ff4be193d5f4f5298929 to your computer and use it in GitHub Desktop.
Save sabopy/fe33f762e1e6ff4be193d5f4f5298929 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
fig,ax = plt.subplots()
ax.axline((0, 0), (.1, .1), linewidth=2, color='C2')
ax.axline((0, 1), (1,0), linewidth=2, color='C4')
ax.axline((0.35, 0.5), (0.75, 0.5), linewidth=2, color='C6')
ax.set_xlim(0,1)
ax.set_ylim(0,1)
plt.savefig("axlines.png",dpi=133)
plt.show()
fig,ax = plt.subplots()
ax.axline((0, 0), (.1, .1), linewidth=2, color='C2')
ax.axline((0, 1), (1,0), linewidth=2, color='C4')
ax.axline((0.35, 0.5), (0.75, 0.5), linewidth=2, color='C6')
ax.set_xlim(-10,10)
ax.set_ylim(-10,10)
plt.savefig("axlines10.png",dpi=133)
plt.show()
fig,ax = plt.subplots()
[ax.axline((0, 0), slope=i, linewidth=1,label="slope="+str(i)+"",color=np.random.rand(3)) for i in np.arange(-5,6,1)]
ax.set_xlim(-100,100)
ax.set_ylim(-100,100)
ax.legend()
plt.savefig("axlines_slope.png",dpi=133)
plt.show()
#version
import matplotlib
print(matplotlib.__version__)
3.3.0
print(np.__version__)
1.19.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment