|
32 | 32 | import matplotlib.pyplot as plt
|
33 | 33 | from plotly.matplotlylib import Exporter, PlotlyRenderer
|
34 | 34 |
|
| 35 | + @pytest.mark.matplotlib |
| 36 | + def test_masked_constants_example(): |
| 37 | + try: |
| 38 | + pd.options.plotting.backend = "matplotlib" |
| 39 | + except Exception: |
| 40 | + pass |
| 41 | + |
| 42 | + # example from: https://gist.github.com/tschaume/d123d56bf586276adb98 |
| 43 | + data = { |
| 44 | + "esN": [0, 1, 2, 3], |
| 45 | + "ewe_is0": [-398.11901997, -398.11902774, -398.11897111, -398.11882215], |
| 46 | + "ewe_is1": [-398.11793027, -398.11792966, -398.11786308, None], |
| 47 | + "ewe_is2": [-398.11397008, -398.11396421, None, None], |
| 48 | + } |
| 49 | + df = pd.DataFrame.from_dict(data) |
| 50 | + |
| 51 | + plotopts = {"x": "esN"} |
| 52 | + fig, ax = plt.subplots(1, 1) |
| 53 | + df.plot(ax=ax, **plotopts) |
| 54 | + |
| 55 | + renderer = PlotlyRenderer() |
| 56 | + Exporter(renderer).run(fig) |
| 57 | + |
| 58 | + _json.dumps(renderer.plotly_fig, cls=utils.PlotlyJSONEncoder) |
| 59 | + |
| 60 | + jy = _json.dumps( |
| 61 | + renderer.plotly_fig["data"][1]["y"], cls=utils.PlotlyJSONEncoder |
| 62 | + ) |
| 63 | + print(jy) |
| 64 | + array = _json.loads(jy) |
| 65 | + assert array == [-398.11793027, -398.11792966, -398.11786308, None] |
| 66 | + |
35 | 67 |
|
36 | 68 | def np_nan():
|
37 | 69 | if Version(np.__version__) < Version("2.0.0"):
|
@@ -431,38 +463,3 @@ def test_no_numpy_int_type(self):
|
431 | 463 | expected_tuple = (int,)
|
432 | 464 |
|
433 | 465 | self.assertEqual(int_type_tuple, expected_tuple)
|
434 |
| - |
435 |
| - |
436 |
| -if matplotlylib: |
437 |
| - |
438 |
| - @pytest.mark.matplotlib |
439 |
| - def test_masked_constants_example(): |
440 |
| - try: |
441 |
| - pd.options.plotting.backend = "matplotlib" |
442 |
| - except Exception: |
443 |
| - pass |
444 |
| - |
445 |
| - # example from: https://gist.github.com/tschaume/d123d56bf586276adb98 |
446 |
| - data = { |
447 |
| - "esN": [0, 1, 2, 3], |
448 |
| - "ewe_is0": [-398.11901997, -398.11902774, -398.11897111, -398.11882215], |
449 |
| - "ewe_is1": [-398.11793027, -398.11792966, -398.11786308, None], |
450 |
| - "ewe_is2": [-398.11397008, -398.11396421, None, None], |
451 |
| - } |
452 |
| - df = pd.DataFrame.from_dict(data) |
453 |
| - |
454 |
| - plotopts = {"x": "esN"} |
455 |
| - fig, ax = plt.subplots(1, 1) |
456 |
| - df.plot(ax=ax, **plotopts) |
457 |
| - |
458 |
| - renderer = PlotlyRenderer() |
459 |
| - Exporter(renderer).run(fig) |
460 |
| - |
461 |
| - _json.dumps(renderer.plotly_fig, cls=utils.PlotlyJSONEncoder) |
462 |
| - |
463 |
| - jy = _json.dumps( |
464 |
| - renderer.plotly_fig["data"][1]["y"], cls=utils.PlotlyJSONEncoder |
465 |
| - ) |
466 |
| - print(jy) |
467 |
| - array = _json.loads(jy) |
468 |
| - assert array == [-398.11793027, -398.11792966, -398.11786308, None] |
0 commit comments