Created
September 5, 2022 12:57
-
-
Save CodeDrome/5eca8a9a1ad28b5f35e6ff79f0039a55 to your computer and use it in GitHub Desktop.
squarerootplot.py
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 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