Skip to content

Commit

Permalink
Merge branch 'feature/#154/advanced_plotting' of https://github.com/p…
Browse files Browse the repository at this point in the history
…ylhc/Beta-Beat.src into feature/#154/advanced_plotting
  • Loading branch information
JoschD committed Oct 10, 2018
2 parents cce961a + ba8fd87 commit 7f47d42
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 4 deletions.
3 changes: 2 additions & 1 deletion plotshop/fig_editor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ def main():
form.show()
app.exec_()


def quick_figure():
import matplotlib.pyplot as plt
fig = plt.figure()
plt.text(.5,.5, "Hallo")
plt.text(.5, .5, "Hallo")
plt.errorbar(range(3), range(3), yerr=range(3), xerr=range(3), capsize=3)
return fig

Expand Down
7 changes: 5 additions & 2 deletions plotshop/fig_editor/options_artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import options_utils as outils
from general_helper import suppress_exception


def change_properties(artist, parent=None):
""" Change the properties of artist via user interface. """
regen_legend = False
Expand Down Expand Up @@ -110,7 +111,6 @@ def _get_axis_properties(axis):

grid_style_data = outils.prepare_formdata(outils.get_linestyles(), grid_style)


# find limits
lim = axis.axes.__getattribute__("get_{}lim".format(plane))()
set_lim_func = axis.axes.__getattribute__("set_{}lim".format(plane))
Expand Down Expand Up @@ -251,7 +251,10 @@ def _get_ebar_properties(ebar):
props += _get_line_properties(ebar[0])[0][3:]

if bar is not None:
ls = "-" # TODO: Could not find the proper way to return the linestyle
ls = bar.get_linestyles()[0][0]
if ls is None:
ls = "None" # it seems as if None here is "Solid" for some reason.
# Workaround: set width to 0

ls_def, ls_choices = outils.prepare_formdata(outils.get_linestyles(), ls)

Expand Down
64 changes: 63 additions & 1 deletion plotshop/fig_editor/serialization.py
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")

0 comments on commit 7f47d42

Please sign in to comment.