
xy0, xmin, xmax, ymin, ymax = f({{ var_name }}{%- if set_const_name %}, {{ set_const_name }}[0]{%- endif %}
{%- for const in constants -%}, {{ const.get('Const. name') }}{%- endfor -%}, {{ x_log }}, {{ y_log }})

# plot setup
graph = kv_graph.GraphAdvanced(xlabel="{{ var_name }}{% if var_unit %} [{{ var_unit }}]{% endif %}",
    ylabel="{{ func_name }}{% if func_unit %} [{{ func_unit }}]{% endif %}",
    x_ticks_major={% if x_log %}0.1{% else %}(xmax-xmin)/10{% endif %},
    y_ticks_major={% if y_log %}0.1{% else %}(ymax-ymin)/10{% endif %},
    y_grid_label=True, x_grid_label=True, padding=5,
    x_grid={{ grid }}, y_grid= {{ grid }}, xlog={{ x_log }}, ylog={{ y_log }},
    xmin=float(xmin),
    xmax=float(xmax)
    {% if y_min %}, ymin=float({{ y_min }}){% endif %}
    {%- if y_max %}, ymax=float({{ y_max }}){%- endif %}
    {%- if plot_title %}, title="{{ plot_title }}"
    {%- else %}, title="{{ func_name }}({{ var_name }})={{ equation }}
    {%- for const in constants %}, {{ const.get('Const. name') }} = {{ const.get('Value') }}
    {%- if const.get('Unit') %} [{{const.get('Unit')}}]{% endif %}
    {%- endfor -%}"{%- endif %}
)

{%- if set_const_name %}
for set_const in {{ set_const_name }}:
{%- if not swap_xy %}
    # plot = kv_graph.MeshLinePlot(color=[1, 0, 0, 1])
    results = f({{ var_name }}, set_const
{%- for const in constants -%}, {{ const.get('Const. name') }}{%- endfor -%}, {{ x_log }}, {{ y_log }})
    # plot.points = results[0]
    graph.plot(results[0], label="{{ set_const_name }}="+str(set_const)
{%- if set_const_unit %}+" [{{ set_const_unit }}]"{% endif %})
{% endif %}
{% else %}
{% if not swap_xy %}
# plot = kv_graph.MeshLinePlot(color=[1, 0, 0, 1])
# points = xy0
# plot.points = points
graph.plot(xy0)
{% endif %}
{% endif %}

