scatter_plot.py 1.41 KB
Newer Older
1 2
# -*- coding: utf-8 -*-

3
import abc
4
from nifty.plotting.plotly_wrapper import PlotlyWrapper
5 6
from nifty.plotting.descriptors import Marker,\
                                       Line
7

8 9

class ScatterPlot(PlotlyWrapper):
Theo Steininger's avatar
Theo Steininger committed
10 11
    def __init__(self, data, label, line, marker):
        self.data = data
12 13 14
        self.label = label
        self.line = line
        self.marker = marker
15 16
        if not self.line and not self.marker:
            self.marker = Marker()
17
            self.line = Line()
18

Theo Steininger's avatar
Theo Steininger committed
19 20 21 22
    @abc.abstractmethod
    def at(self, data):
        raise NotImplementedError

23 24 25 26 27
    @abc.abstractproperty
    def figure_dimension(self):
        raise NotImplementedError

    @abc.abstractmethod
28 29 30 31 32 33 34 35
    def to_plotly(self):
        ply_object = dict()
        ply_object['name'] = self.label
        if self.line and self.marker:
            ply_object['mode'] = 'lines+markers'
            ply_object['line'] = self.line.to_plotly()
            ply_object['marker'] = self.marker.to_plotly()
        elif self.line:
36
            ply_object['mode'] = 'line'
37 38
            ply_object['line'] = self.line.to_plotly()
        elif self.marker:
39
            ply_object['mode'] = 'markers'
40 41 42
            ply_object['marker'] = self.marker.to_plotly()

        return ply_object
43 44

    def default_width(self):
Theo Steininger's avatar
Theo Steininger committed
45
        return 1100
46 47 48 49 50 51 52

    def default_height(self):
        return 700

    @abc.abstractmethod
    def default_axes(self):
        raise NotImplementedError