MCPcopy Index your code
hub / github.com/plotly/plotly.py / PlotlyRenderer

Class PlotlyRenderer

plotly/matplotlylib/renderer.py:17–818  ·  view source on GitHub ↗

A renderer class inheriting from base for rendering mpl plots in plotly. A renderer class to be used with an exporter for rendering matplotlib plots in Plotly. This module defines the PlotlyRenderer class which handles the creation of the JSON structures that get sent to plotly. Al

Source from the content-addressed store, hash-verified

15
16
17class PlotlyRenderer(Renderer):
18 """A renderer class inheriting from base for rendering mpl plots in plotly.
19
20 A renderer class to be used with an exporter for rendering matplotlib
21 plots in Plotly. This module defines the PlotlyRenderer class which handles
22 the creation of the JSON structures that get sent to plotly.
23
24 All class attributes available are defined in __init__().
25
26 Basic Usage:
27
28 # (mpl code) #
29 fig = gcf()
30 renderer = PlotlyRenderer(fig)
31 exporter = Exporter(renderer)
32 exporter.run(fig) # ... et voila
33
34 """
35
36 def __init__(self):
37 """Initialize PlotlyRenderer obj.
38
39 PlotlyRenderer obj is called on by an Exporter object to draw
40 matplotlib objects like figures, axes, text, etc.
41
42 All class attributes are listed here in the __init__ method.
43
44 """
45 self.plotly_fig = go.Figure()
46 self.mpl_fig = None
47 self.current_mpl_ax = None
48 self.bar_containers = None
49 self.current_bars = []
50 self.axis_ct = 0
51 self.x_is_mpl_date = False
52 self.mpl_x_bounds = (0, 1)
53 self.mpl_y_bounds = (0, 1)
54 self.msg = "Initialized PlotlyRenderer\n"
55 self._processing_legend = False
56 self._legend_visible = False
57
58 def open_figure(self, fig, props):
59 """Creates a new figure by beginning to fill out layout dict.
60
61 The 'autosize' key is set to false so that the figure will mirror
62 sizes set by mpl. The 'hovermode' key controls what shows up when you
63 mouse around a figure in plotly, it's set to show the 'closest' point.
64
65 Positional agurments:
66 fig -- a matplotlib.figure.Figure object.
67 props.keys(): [
68 'figwidth',
69 'figheight',
70 'dpi'
71 ]
72
73 """
74 self.msg += "Opening figure\n"

Callers 2

run_figFunction · 0.90

Calls

no outgoing calls

Tested by 1