Ejemplo n.º 1
0
    def test_masked_constants_example():
        # example from: https://gist.github.com/tschaume/d123d56bf586276adb98
        data = {
            "esN": [0, 1, 2, 3],
            "ewe_is0":
            [-398.11901997, -398.11902774, -398.11897111, -398.11882215],
            "ewe_is1": [-398.11793027, -398.11792966, -398.11786308, None],
            "ewe_is2": [-398.11397008, -398.11396421, None, None],
        }
        df = pd.DataFrame.from_dict(data)

        plotopts = {"x": "esN"}
        fig, ax = plt.subplots(1, 1)
        df.plot(ax=ax, **plotopts)

        renderer = PlotlyRenderer()
        Exporter(renderer).run(fig)

        _json.dumps(renderer.plotly_fig, cls=utils.PlotlyJSONEncoder)

        jy = _json.dumps(renderer.plotly_fig["data"][1]["y"],
                         cls=utils.PlotlyJSONEncoder)
        print(jy)
        array = _json.loads(jy)
        assert array == [-398.11793027, -398.11792966, -398.11786308, None]
Ejemplo n.º 2
0
def test_masked_constants_example():
    # example from: https://gist.github.com/tschaume/d123d56bf586276adb98
    data = {
        'esN': [0, 1, 2, 3],
        'ewe_is0':
        [-398.11901997, -398.11902774, -398.11897111, -398.11882215],
        'ewe_is1': [-398.11793027, -398.11792966, -398.11786308, None],
        'ewe_is2': [-398.11397008, -398.11396421, None, None]
    }
    df = pd.DataFrame.from_dict(data)

    plotopts = {'x': 'esN', 'marker': 'o'}
    fig, ax = plt.subplots(1, 1)
    df.plot(ax=ax, **plotopts)

    renderer = PlotlyRenderer()
    Exporter(renderer).run(fig)

    json.dumps(renderer.plotly_fig, cls=utils.PlotlyJSONEncoder)

    jy = json.dumps(renderer.plotly_fig['data'][1]['y'],
                    cls=utils.PlotlyJSONEncoder)
    print(jy)
    array = json.loads(jy)
    assert (array == [-398.11793027, -398.11792966, -398.11786308, None])
Ejemplo n.º 3
0
def run_fig(fig):
    renderer = PlotlyRenderer()
    exporter = Exporter(renderer)
    print(exporter)
    exporter.run(fig)
    return renderer
Ejemplo n.º 4
0
def run_fig(fig):
    renderer = PlotlyRenderer()
    exporter = Exporter(renderer)
    exporter.run(fig)
    return renderer