-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/#154/advanced_plotting' of https://github.com/p…
…ylhc/Beta-Beat.src into feature/#154/advanced_plotting
- Loading branch information
Showing
3 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,71 @@ | ||
from utils.contexts import suppress_exception | ||
from utils.dict_tools import DotDict | ||
|
||
|
||
|
||
|
||
def line_to_struct(line): | ||
pass | ||
""" Converts a line to a dictionary structure of plotly-standard. | ||
See https://plot.ly/python/reference/#scatter | ||
""" | ||
ls = DotDict() | ||
ls.name = line.get_name() | ||
ls.visible = line.get_visible() | ||
ls.x = line.get_xdata() | ||
ls.y = line.get_ydata() | ||
ls.mode = _get_mode(line) | ||
|
||
ls.line = DotDict() | ||
ls.line.color = line.get_color() | ||
ls.line.width = line.get_width() | ||
ls.line.dash = line.get_linestyle() | ||
|
||
|
||
def struct_to_line(ax, struct): | ||
pass | ||
|
||
|
||
|
||
def linestyle_to_dash(ls): | ||
""" Map linestyle to dash_names """ | ||
return { | ||
"-": "solid", | ||
"--": "dash", | ||
".": "dot", | ||
"-.": "dashdot", | ||
}[ls] | ||
|
||
|
||
def dash_to_linestyle(dash): | ||
try: | ||
return { | ||
"solid": "-", | ||
"dash": "--", | ||
"dot": ".", | ||
"dashdot": "-.", | ||
"longdash": "--", | ||
"longdashdot": "-.", | ||
}[dash] | ||
except KeyError: | ||
return "--" | ||
|
||
|
||
def _get_mode(line): | ||
""" Returns 'lines', 'markers' or 'lines+markers'. | ||
""" | ||
mode = [] | ||
ls = line.get_linestyle() | ||
ms = line.get_marker() | ||
if "none" != ls.lower(): | ||
mode.append("lines") | ||
if "none" != ms.lower(): | ||
mode.append("markers") | ||
return "+".join(mode) | ||
|
||
|
||
def _set_mode(line, mode): | ||
""" Sets lines or markers to None if not in mode. """ | ||
if "lines" not in mode: | ||
line.set_linestyle("None") | ||
if "markers" not in mode: | ||
line.set_marker("None") |