Skip to content
Snippets Groups Projects
Unverified Commit 57b63ae6 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

don't abort when no points to plot

this will allow to have "phantom" legend for more complex graphs
```nushell
let xs = seq 0 0.1 20

let graphs = [
    {
        points: ($xs | each {|x| {
            x: $x,
            y: (1.1 * $x ** 2),
            e: (0.1 + 0.5 * $x),
        }}),
        style: {
            color: "tab:blue",
            line: {
                type: "solid",
                marker: {
                    size: 0,
                },
            },
        },
    },
    {
        points: ($xs | each {|x| {
            x: $x,
            y: (1.5 * $x ** 2),
            e: (0.1 + 0.5 * $x),
        }}),
        style: {
            color: "tab:orange",
            line: {
                type: "solid",
                marker: {
                    size: 0,
                },
            },
        },
    },
    {
        points: ($xs | each {|x| {
            x: $x,
            y: (10 + 100 * 1.1 * ($x | math sqrt)),
            e: (0.1 + 0.5 * ($x | math sqrt)),
        }}),
        style: {
            color: "tab:blue",
            line: {
                type: "dashed",
                marker: {
                    size: 0,
                },
            },
        },
    },
    {
        points: ($xs | each {|x| {
            x: $x,
            y: (10 + 100 * 1.5 * ($x | math sqrt)),
            e: (0.1 + 0.5 * ($x | math sqrt)),
        }}),
        style: {
            color: "tab:orange",
            line: {
                type: "dashed",
                marker: {
                    size: 0,
                },
            },
        },
    },

    {
        name: "$\\alpha = 1.5$",
        points: [],
        style: {
            color: "tab:orange",
            line: {
                type: "solid",
                marker: {
                    size: 0,
                },
            },
        },
    }
    {
        name: "$\\alpha = 1.1$",
        points: [],
        style: {
            color: "tab:blue",
            line: {
                type: "solid",
                marker: {
                    size: 0,
                },
            },
        },
    }
    {
        name: "$f: x \\rightarrow \\alpha x^2$",
        points: [],
        style: {
            color: "tab:grey",
            line: {
                type: "solid",
                marker: {
                    size: 0,
                },
            },
        },
    }
    {
        name: "$f: x \\rightarrow 10 + 100 \\alpha \\sqrt{x}$",
        points: [],
        style: {
            color: "tab:grey",
            line: {
                type: "dashed",
                marker: {
                    size: 0,
                },
            },
        },
    }
]

python src/main.py plot ($graphs | to json) ...[
    --x-label "$x$"
    --y-label "$f(x)$"
    --fullscreen
    --dpi 50
    --use-tex
]
```
parent 9c946bcd
Branches
Tags 0.7.0
No related merge requests found
......@@ -186,7 +186,6 @@ def _plot_single(g: Graph, i: int, ax: matplotlib.axes.Axes):
xs, ys, es = _parse_graph_points(g["points"], name)
if len(xs) == 0:
warning(f"no point to plot for graph {name}")
return
line_style, error_alpha = _parse_graph_style(g)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment