Skip to content

Commit

Permalink
Merge pull request #1 from realjanpaulus/coding
Browse files Browse the repository at this point in the history
add: startvalue param
  • Loading branch information
realjanpaulus authored Nov 19, 2020
2 parents 37e77fa + 2506b93 commit 05a2766
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/functionplotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def get_function(function = "constant", space=(-10.0, 10.0), **kwargs):

def get_slider(value_names = ["x", "w"],
space = (-10.0, 10.0),
slider_step = 1.0):
slider_step = 1.0,
startvalue = 0):
""" Returns a slider element in a list for
every value in value_names.
"""
Expand All @@ -108,7 +109,7 @@ def get_slider(value_names = ["x", "w"],
orientation='horizontal',
readout=True,) for i in ["Funktion"]]
else:
return [widgets.FloatSlider(value=0,
return [widgets.FloatSlider(value=startvalue,
min=space[0],
max=space[1],
step=slider_step,
Expand All @@ -127,7 +128,8 @@ def get_slider(value_names = ["x", "w"],

def plt_function(function = "constant",
space=(-10.0, 10.0),
slider_step = 1.0):
slider_step = 1.0,
startvalue=0):
""" Plot function by function name. """
available_functions = ["constant", "exponential", "linear", "logarithmic",
"normal_parabola", "power", "quadratic", "trigonometric"]
Expand All @@ -150,7 +152,7 @@ def plt_function(function = "constant",
elif function == "trigonometric":
value_names = ["cos", "sin", "tan"]

sliders = get_slider(value_names, space=space, slider_step=slider_step)
sliders = get_slider(value_names, space=space, slider_step=slider_step, startvalue=startvalue)
kwargs = {'v{}'.format(i+1):slider for i, slider in enumerate(sliders)}
interact(get_function, function=fixed(function), space=fixed(space), **kwargs)
else:
Expand Down

0 comments on commit 05a2766

Please sign in to comment.