Skip to content

Instantly share code, notes, and snippets.

@CodeDrome
Created September 5, 2022 12:57
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 CodeDrome/5eca8a9a1ad28b5f35e6ff79f0039a55 to your computer and use it in GitHub Desktop.
Save CodeDrome/5eca8a9a1ad28b5f35e6ff79f0039a55 to your computer and use it in GitHub Desktop.
squarerootplot.py
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
def plot(valuerange, sqrts=None):
matplotlib.pyplot.figure(figsize=(10,8), facecolor="#FFFFFF")
plt.title('Square Roots in Python ')
values = np.array(range(valuerange[0], valuerange[1]+1))
npsqrts = np.sqrt(values)
plt.plot(values,
npsqrts,
label='NumPy sqrt',
color='#0000FF',
alpha=0.25,
linewidth=4)
if sqrts != None:
for sqrt in sqrts:
plt.plot(values,
sqrt["sqrts"],
label=sqrt["label"],
color=sqrt["color"],
linewidth=1.0)
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment