|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | + |
| 4 | +__all__ = [ |
| 5 | + 'plot_schema', |
| 6 | + 'set_plot_schema', |
| 7 | +] |
| 8 | + |
| 9 | +from .stability import (CENTER_MANIFOLD, SADDLE_NODE, STABLE_POINT_1D, |
| 10 | + UNSTABLE_POINT_1D, CENTER_2D, STABLE_NODE_2D, |
| 11 | + STABLE_FOCUS_2D, STABLE_STAR_2D, STABLE_DEGENERATE_2D, |
| 12 | + UNSTABLE_NODE_2D, UNSTABLE_FOCUS_2D, UNSTABLE_STAR_2D, |
| 13 | + UNSTABLE_DEGENERATE_2D, UNSTABLE_LINE_2D, |
| 14 | + STABLE_POINT_3D, UNSTABLE_POINT_3D, STABLE_NODE_3D, |
| 15 | + UNSTABLE_SADDLE_3D, UNSTABLE_NODE_3D, STABLE_FOCUS_3D, |
| 16 | + UNSTABLE_FOCUS_3D, UNSTABLE_CENTER_3D, UNKNOWN_3D) |
| 17 | + |
| 18 | + |
| 19 | +_markersize = 20 |
| 20 | + |
| 21 | +plot_schema = {} |
| 22 | + |
| 23 | +plot_schema[CENTER_MANIFOLD] = {'color': 'orangered', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'} |
| 24 | +plot_schema[SADDLE_NODE] = {"color": 'tab:blue', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'} |
| 25 | + |
| 26 | +plot_schema[STABLE_POINT_1D] = {"color": 'tab:red', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'} |
| 27 | +plot_schema[UNSTABLE_POINT_1D] = {"color": 'tab:olive', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'} |
| 28 | + |
| 29 | +plot_schema.update({ |
| 30 | + CENTER_2D: {'color': 'lime', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 31 | + STABLE_NODE_2D: {"color": 'tab:red', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 32 | + STABLE_FOCUS_2D: {"color": 'tab:purple', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 33 | + STABLE_STAR_2D: {'color': 'tab:olive', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 34 | + STABLE_DEGENERATE_2D: {'color': 'blueviolet', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 35 | + UNSTABLE_NODE_2D: {"color": 'tab:orange', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 36 | + UNSTABLE_FOCUS_2D: {"color": 'tab:cyan', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 37 | + UNSTABLE_STAR_2D: {'color': 'green', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 38 | + UNSTABLE_DEGENERATE_2D: {'color': 'springgreen', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 39 | + UNSTABLE_LINE_2D: {'color': 'dodgerblue', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 40 | +}) |
| 41 | + |
| 42 | + |
| 43 | +plot_schema.update({ |
| 44 | + STABLE_POINT_3D: {'color': 'tab:gray', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 45 | + UNSTABLE_POINT_3D: {'color': 'tab:purple', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 46 | + STABLE_NODE_3D: {'color': 'tab:green', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 47 | + UNSTABLE_SADDLE_3D: {'color': 'tab:red', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 48 | + UNSTABLE_FOCUS_3D: {'color': 'tab:pink', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 49 | + STABLE_FOCUS_3D: {'color': 'tab:purple', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 50 | + UNSTABLE_NODE_3D: {'color': 'tab:orange', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 51 | + UNSTABLE_CENTER_3D: {'color': 'tab:olive', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 52 | + UNKNOWN_3D: {'color': 'tab:cyan', 'markersize': _markersize, 'linestyle': 'None', 'marker': '.'}, |
| 53 | +}) |
| 54 | + |
| 55 | + |
| 56 | +def set_plot_schema(fixed_point: str, **schema): |
| 57 | + if not isinstance(fixed_point, str): |
| 58 | + raise TypeError(f'Must instance of string, but we got {type(fixed_point)}: {fixed_point}') |
| 59 | + if fixed_point not in plot_schema: |
| 60 | + raise KeyError(f'Fixed point type {fixed_point} does not found in the built-in types. ') |
| 61 | + plot_schema[fixed_point].update(**schema) |
| 62 | + |
| 63 | + |
| 64 | +def set_markersize(markersize): |
| 65 | + if not isinstance(markersize, int): |
| 66 | + raise TypeError(f"Must be an integer, but got {type(markersize)}: {markersize}") |
| 67 | + global _markersize |
| 68 | + __markersize = markersize |
| 69 | + for key in tuple(plot_schema.keys()): |
| 70 | + plot_schema[key]['markersize'] = markersize |
| 71 | + |
| 72 | + |
0 commit comments