Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: startvalue param #1

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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