[Python-modules-commits] [python-mplexporter] 44/135: Merge remote-tracking branch 'mpld3/master'

Wolfgang Borgert debacle at moszumanska.debian.org
Tue Sep 23 21:19:02 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-mplexporter.

commit aec2fbe70f71faab4c81265194da340c8fa8bbf9
Merge: 1f19ea6 02fde6c
Author: theengineear <andseier at gmail.com>
Date:   Mon Feb 24 23:48:43 2014 -0800

    Merge remote-tracking branch 'mpld3/master'
    
    Conflicts:
    	mplexporter/renderers/plotly/plotly_renderer.py
    
    Added mplobj keyword argument to Plotly Renderer

 mplexporter/exporter.py                         | 194 ++++++++++++-----
 mplexporter/renderers/__init__.py               |   8 +
 mplexporter/renderers/base.py                   | 264 +++++++++++++++++++++++-
 mplexporter/renderers/example_renderer.py       |   4 +-
 mplexporter/renderers/plotly/plotly_renderer.py |  30 +++
 mplexporter/renderers/vega_renderer.py          |   4 +-
 mplexporter/renderers/vincent_renderer.py       |   4 +-
 mplexporter/tests/test_utils.py                 |  11 +
 mplexporter/utils.py                            | 164 +++++++++++++--
 notebooks/PlotlyTest.ipynb                      |  16 +-
 notebooks/VegaTest.ipynb                        |  14 +-
 notebooks/VincentTest.ipynb                     |  22 +-
 12 files changed, 632 insertions(+), 103 deletions(-)

diff --cc mplexporter/renderers/plotly/plotly_renderer.py
index 6dfd149,625a38a..2881d53
--- a/mplexporter/renderers/plotly/plotly_renderer.py
+++ b/mplexporter/renderers/plotly/plotly_renderer.py
@@@ -26,110 -26,54 +26,140 @@@ class PlotlyRenderer(Renderer)
  
      def close_figure(self, fig):
          self.output += "closing figure\n"
 +        self.configure_subplots()
 +        self.configure_primary_axes()  # changes 'y1', 'xaxis1', etc. to 'y', 'xaxis', etc.
 +        self.layout['showlegend'] = False
  
      def open_axes(self, ax, properties):
 -        self.output += "  opening axes\n"
          self.axis_ct += 1
 -        layout = {}
 -        layout['title'] = properties['title']
 -        xaxis = {}
 -        xaxis['range'] = properties['xlim']
 -        xaxis['title'] = properties['xlabel']
 -        xaxis['showgrid'] = properties['xgrid']
 -        yaxis = {}
 -        yaxis['range'] = properties['ylim']
 -        yaxis['title'] = properties['ylabel']
 -        yaxis['showgrid'] = properties['ygrid']
 -        layout['xaxis'] = xaxis
 -        layout['yaxis'] = yaxis
 -        self.layout = layout
 +        self.output += "  opening axis {}\n".format(self.axis_ct)
 +        layout = {
 +            'title': properties['title'],
 +            'xaxis{}'.format(self.axis_ct): {
 +                'range': properties['xlim'],
 +                'title': properties['xlabel'],
 +                'showgrid': properties['xgrid']
 +            },
 +            'yaxis{}'.format(self.axis_ct): {
 +                'domain': [0,1],
 +                'range': properties['ylim'],
 +                'title': properties['ylabel'],
 +                'showgrid': properties['ygrid'],
 +            }
 +        }
 +        for key, value in layout.items():
 +            self.layout[key] = value
  
      def close_axes(self, ax):
 -        self.output += "  closing axes\n"
 +        self.output += "  closing axis {}\n".format(self.axis_ct)
  
++<<<<<<< HEAD
 +    def draw_line(self, data, coordinates, style):
 +        if coordinates == 'data':
 +            self.output += "    draw line with {0} points\n".format(data.shape[0])
 +            trace = {
 +                'mode': 'lines',
 +                'x': [xy_pair[0] for xy_pair in data],
 +                'y': [xy_pair[1] for xy_pair in data],
 +                'xaxis': 'x{}'.format(self.axis_ct),
 +                'yaxis': 'y{}'.format(self.axis_ct),
 +                'line': {
 +                    'opacity': style['alpha'],
 +                    'color': style['color'],
 +                    'width': style['linewidth'],
 +                    'dash': plotly_utils.convert_dash(style['dasharray'])
 +                }
 +            }
 +            self.data += trace,
 +        else:
 +            self.output += "    received {}-point line with 'figure' coordinates, skipping!".format(data.shape[0])
 +
 +    def draw_markers(self, data, coordinates, style):
 +        if coordinates == 'data':
 +            self.output += "    draw {0} markers\n".format(data.shape[0])
 +            trace = {
 +                'mode': 'markers',
 +                'x': [xy_pair[0] for xy_pair in data],
 +                'y': [xy_pair[1] for xy_pair in data],
 +                'xaxis': 'x{}'.format(self.axis_ct),
 +                'yaxis': 'y{}'.format(self.axis_ct),
 +                'marker': {
 +                    'opacity': style['alpha'],
 +                    'color': style['facecolor'],
 +                    'symbol': plotly_utils.convert_symbol(style['marker']),
 +                    'line': {
 +                        'color': style['edgecolor'],
 +                        'width': style['edgewidth']
 +                    }
 +                }
 +            }
 +            # not sure whether we need to incorporate style['markerpath']
 +            self.data += trace,
 +        else:
 +            self.output += "    received {} markers with 'figure' coordinates, skipping!".format(data.shape[0])
 +
 +    def configure_subplots(self):
 +        num_plots = self.axis_ct
 +        if num_plots > 1:
 +            spacing = 0.3/num_plots # magic numbers! change this!
 +            plot_dim = (1 - spacing*(num_plots-1))/num_plots
 +            for subplot_num in range(0, num_plots):
 +                domain_end = 1 - (plot_dim + spacing)*subplot_num
 +                domain_start = domain_end - plot_dim
 +                if domain_start < 0:
 +                    domain_start = 0
 +                self.layout['yaxis{}'.format(subplot_num + 1)]['domain'] = [domain_start, domain_end]
 +                self.layout['xaxis{}'.format(subplot_num + 1)]['anchor'] = 'y{}'.format(subplot_num + 1)
 +
 +    def configure_primary_axes(self):
 +        for trace in self.data:
 +            if trace['xaxis'] == 'x1':
 +                trace['xaxis'] = 'x'
 +            if trace['yaxis'] == 'y1':
 +                trace['yaxis'] = 'y'
 +        if 'xaxis1' in self.layout:
 +            self.layout['xaxis'] = self.layout.pop('xaxis1')
 +        if 'yaxis1' in self.layout:
 +            self.layout['yaxis'] = self.layout.pop('yaxis1')
 +        try:
 +            if 'y1' in self.layout['xaxis']['anchor']:
 +                self.layout['xaxis']['anchor'] = 'y'
 +        except KeyError:
 +            pass
 +        try:
 +            if 'x1' in self.layout['yaxis']['anchor']:
 +                self.layout['yaxis']['anchor'] = 'x'
 +        except KeyError:
 +            pass
++=======
+     def draw_line(self, data, coordinates, style, mplobj=None):
+         self.output += "    draw line with {0} points\n".format(data.shape[0])
+         data_dict = {'x': [], 'y': []}
+         for xy_pair in data:
+             data_dict['x'] += [xy_pair[0]]
+             data_dict['y'] += [xy_pair[1]]
+         data_dict['mode'] = 'lines'
+         data_dict['line'] = {}
+         data_dict['line']['opacity'] = style['alpha']
+         data_dict['line']['width'] = style['linewidth']
+         data_dict['line']['dash'] = plotly_utils.convert_dash(style['dasharray'])
+         self.data += data_dict,
+ 
+     def draw_markers(self, data, coordinates, style, mplobj=None):
+         self.output += "    draw {0} markers\n".format(data.shape[0])
+         data_dict = {'x': [], 'y': []}
+         for xy_pair in data:
+             data_dict['x'] += [xy_pair[0]]
+             data_dict['y'] += [xy_pair[1]]
+         data_dict['mode'] = 'markers'
+         data_dict['marker'] = {}
+         data_dict['marker']['opacity'] = style['alpha']
+         data_dict['marker']['color'] = style['facecolor']
+         # need to incorporate style['edgecolor']
+         data_dict['marker']['symbol'] = plotly_utils.convert_symbol(style['marker'])
+         # not sure whether we need to incorporate style['markerpath']
+         self.data += data_dict,
++>>>>>>> mpld3/master
  
  
  def fig_to_plotly(fig, username=None, api_key=None, notebook=False):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-mplexporter.git



More information about the Python-modules-commits mailing list