Ë
    {�h…Š  ã                   ó`   — d Z ddlZddlmZ ddlmZ ddlmZ dd„Z	e	e_
         G d„ de«      Zy)	zÄ
Renderer Module

This module defines the PlotlyRenderer class and a single function,
fig_to_plotly, which is intended to be the main way that user's will interact
with the matplotlylib package.

é    N)ÚRenderer)Úmpltoolsc                 ó2   — |›d|›d|j                   ›d| ›d�S )Nú:z: z:

z

)Ú__name__)ÚmsgÚcategoryÚfilenameÚlinenoÚfileÚlines         úZ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/plotly/matplotlylib/renderer.pyÚwarning_on_one_liner      s   € Ú%-ªv°x×7HÓ7HÊ#ÐNÐNó    c                   ó|   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚPlotlyRenderera
  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.

    All class attributes available are defined in __init__().

    Basic Usage:

    # (mpl code) #
    fig = gcf()
    renderer = PlotlyRenderer(fig)
    exporter = Exporter(renderer)
    exporter.run(fig)  # ... et voila

    c                 ó´   — t        j                  «       | _        d| _        d| _        d| _        g | _        d| _        d| _        d| _	        d| _
        d| _        y)zïInitialize PlotlyRenderer obj.

        PlotlyRenderer obj is called on by an Exporter object to draw
        matplotlib objects like figures, axes, text, etc.

        All class attributes are listed here in the __init__ method.

        Nr   F)r   é   zInitialized PlotlyRenderer
)ÚgoÚFigureÚ
plotly_figÚmpl_figÚcurrent_mpl_axÚbar_containersÚcurrent_barsÚaxis_ctÚx_is_mpl_dateÚmpl_x_boundsÚmpl_y_boundsr   ©Úselfs    r   Ú__init__zPlotlyRenderer.__init__+   sV   € ô Ÿ)™)›+ˆŒØˆŒØ"ˆÔØ"ˆÔØˆÔØˆŒØ"ˆÔØ"ˆÔØ"ˆÔØ1ˆ�r   c           
      óÔ  — | xj                   dz  c_         || _        t        j                  t	        |d   |d   z  «      t	        |d   |d   z  «      dd¬«      | j
                  d<   t        j                  |«      \  | _        | _	        t        j                  j                  t	        | j                  d	   | j
                  d   d
   z  «      t	        d| j                  d   z
  | j
                  d   d
   z  «      t	        d| j                  d   z
  | j
                  d   d   z  «      t	        | j                  d	   | j
                  d   d   z  «      d	¬«      }|| j
                  d   d<   y)aæ  Creates a new figure by beginning to fill out layout dict.

        The 'autosize' key is set to false so that the figure will mirror
        sizes set by mpl. The 'hovermode' key controls what shows up when you
        mouse around a figure in plotly, it's set to show the 'closest' point.

        Positional agurments:
        fig -- a matplotlib.figure.Figure object.
        props.keys(): [
            'figwidth',
            'figheight',
            'dpi'
            ]

        zOpening figure
ÚfigwidthÚdpiÚ	figheightFÚclosest)ÚwidthÚheightÚautosizeÚ	hovermodeÚlayoutr   r(   r   r)   )ÚlÚrÚtÚbÚpadÚmarginN)r   r   r   ÚLayoutÚintr   r   Úget_axes_boundsr   r   r,   ÚMargin)r!   ÚfigÚpropsr2   s       r   Úopen_figurezPlotlyRenderer.open_figure?   sS  € ð  	�ŠÐ&Ñ&�ØˆŒÜ$&§I¡IÜ�e˜JÑ'¨%°©,Ñ6Ó7Ü�u˜[Ñ)¨E°%©LÑ8Ó9ØØô	%
ˆ�‰˜Ñ!ô 08×/GÑ/GÈÓ/LÑ,ˆÔ˜4Ô,Ü—‘×!Ñ!Ü�$×#Ñ# AÑ&¨¯©¸Ñ)BÀ7Ñ)KÑKÓLÜ�1�t×(Ñ(¨Ñ+Ñ+¨t¯©¸xÑ/HÈÑ/QÑQÓRÜ�1�t×(Ñ(¨Ñ+Ñ+¨t¯©¸xÑ/HÈÑ/RÑRÓSÜ�$×#Ñ# AÑ&¨¯©¸Ñ)BÀ8Ñ)LÑLÓMØð "ó 
ˆð /5ˆ�‰˜Ñ! (Ò+r   c                 óR   — d| j                   d   d<   | xj                  dz  c_        y)a  Closes figure by cleaning up data and layout dictionaries.

        The PlotlyRenderer's job is to create an appropriate set of data and
        layout dictionaries. When the figure is closed, some cleanup and
        repair is necessary. This method removes inappropriate dictionary
        entries, freeing up Plotly to use defaults and best judgements to
        complete the entries. This method is called by an Exporter object.

        Positional arguments:
        fig -- a matplotlib.figure.Figure object.

        Fr,   Ú
showlegendzClosing figure
N)r   r   )r!   r7   s     r   Úclose_figurezPlotlyRenderer.close_figurea   s&   € ð 38ˆ�‰˜Ñ! ,Ñ/Ø�ŠÐ&Ñ&Žr   c                 óŽ  — | xj                   dz  c_         || _        |j                  D �cg c]  }|j                  j                  dk(  r|‘Œ c}| _        g | _        | xj                  dz  c_        t        j                  j                  dj                  | j                  «      dd¬«      }t        j                  j                  dj                  | j                  «      dd¬«      }t        j                  ||| j                  | j                   ¬	«      \  }}|j#                  |«       |j#                  |«       t        j$                  |d
«      }t        j$                  |d«      }	t        j$                  |d«      }
t        j$                  |d«      }t        j&                  ||	«      |d<   t        j&                  |
|«      |d<   ||d<   |	|d<   || j(                  d   dj                  | j                  «      <   || j(                  d   dj                  | j                  «      <   dt+        |«      v r|d   dk(  rd| _        yyyc c}w )a;  Setup a new axes object (subplot in plotly).

        Plotly stores information about subplots in different 'xaxis' and
        'yaxis' objects which are numbered. These are just dictionaries
        included in the layout dictionary. This function takes information
        from the Exporter, fills in appropriate dictionary entries,
        and updates the layout dictionary. PlotlyRenderer keeps track of the
        number of plots by incrementing the axis_ct attribute.

        Setting the proper plot domain in plotly is a bit tricky. Refer to
        the documentation for mpltools.convert_x_domain and
        mpltools.convert_y_domain.

        Positional arguments:
        ax -- an mpl axes object. This will become a subplot in plotly.
        props.keys() -- [
            'axesbg',           (background color for axes obj)
            'axesbgalpha',      (alpha, or opacity for background)
            'bounds',           ((x0, y0, width, height) for axes)
            'dynamic',          (zoom/pan-able?)
            'axes',             (list: [xaxis, yaxis])
            'xscale',           (log, linear, or date)
            'yscale',
            'xlim',             (range limits for x)
            'ylim',
            'xdomain'           (xdomain=xlim, unless it's a date)
            'ydomain'
            ]

        z  Opening axes
ÚBarContainerr   úy{0}FÚinside)ÚanchorÚzerolineÚticksúx{0})Úaxr8   Úx_boundsÚy_boundsÚbottomÚtopÚleftÚrightÚmirrorÚshowliner,   úxaxis{0}úyaxis{0}ÚtypeÚdateTN)r   r   Ú
containersÚ	__class__r   r   r   r   r   r,   ÚXAxisÚformatÚYAxisr   Úprep_xy_axisr   r   ÚupdateÚget_spine_visibleÚget_axis_mirrorr   Údirr   )r!   rE   r8   ÚcÚxaxisÚyaxisÚ	mpl_xaxisÚ	mpl_yaxisÚbottom_spineÚ	top_spineÚ
left_spineÚright_spines               r   Ú	open_axeszPlotlyRenderer.open_axesq   s  € ð> 	�ŠÐ&Ñ&�Ø ˆÔð —]‘]ö
àØ�{‰{×#Ñ# ~Ò5ò ò
ˆÔð
 ˆÔØ�Š˜Ñ�ä—	‘	—‘Ø—=‘= §¡Ó.¸Àhð  ó 
ˆô —	‘	—‘Ø—=‘= §¡Ó.¸Àhð  ó 
ˆô  (×4Ñ4Ø˜¨×):Ñ):ÀT×EVÑEVô 
Ñˆ	�9ð 	�‰�YÔØ�‰�YÔÜ×1Ñ1°"°hÓ?ˆÜ×.Ñ.¨r°5Ó9ˆ	Ü×/Ñ/°°FÓ;ˆ
Ü×0Ñ0°°WÓ=ˆÜ"×2Ñ2°<ÀÓKˆˆh‰Ü"×2Ñ2°:¸{ÓKˆˆh‰Ø(ˆˆjÑØ%ˆˆjÑð FKˆ�‰˜Ñ! *×"3Ñ"3°D·L±LÓ"AÑBØEJˆ�‰˜Ñ! *×"3Ñ"3°D·L±LÓ"AÑBð ”S˜“ZÑ E¨&¡M°VÒ$;Ø!%ˆDÕð %<ÐùòG
s   «"Ic                 ór   — | j                  | j                  «       | xj                  dz  c_        d| _        y)a€  Close the axes object and clean up.

        Bars from bar charts are given to PlotlyRenderer one-by-one,
        thus they need to be taken care of at the close of each axes object.
        The self.current_bars variable should be empty unless a bar
        chart has been created.

        Positional arguments:
        ax -- an mpl axes object, not required at this time.

        z  Closing axes
FN)Ú	draw_barsr   r   r   )r!   rE   s     r   Ú
close_axeszPlotlyRenderer.close_axes¸   s-   € ð 	�‰�t×(Ñ(Ô)Ø�ŠÐ&Ñ&�Ø"ˆÕr   c                 óÄ   — g }| j                   D ]2  }|j                  | j                  D �cg c]  }|d   |v r|‘Œ c}«       Œ4 |D ]  }| j                  |«       Œ y c c}w )NÚmplobj)r   Úappendr   Údraw_bar)r!   ÚbarsÚ
mpl_tracesÚ	containerÚ	bar_propsÚtraces         r   rg   zPlotlyRenderer.draw_barsÈ   sy   € ð ˆ
Ø×,Ñ,ò 	ˆIØ×Ñð &*×%6Ñ%6öà!Ø  Ñ*¨iÑ7ò òõð	ð  ò 	!ˆEØ�M‰M˜%Õ ñ	!ùòs   «A
c                 óî	  ‡‡‡— d}|D �cg c]  }t        j                  d$i |¤Ž‘Œ }}|D �cg c]  }|d   |d   z
  ‘Œ c}Š|D �cg c]  }|d   |d   z
  ‘Œ c}Št        t        ˆfd„t	        t        ‰«      «      D «       «      «      |k  }t        t        ˆfd„t	        t        ‰«      «      D «       «      «      |k  }|rD|rB|D �cg c]  }|d   ‘Œ	 c}Št        ˆfd„t	        t        ‰d	d
 «      «      D «       «      rd}n
d}n|rd}nd}|dk(  �r|| xj                  dz  c_        |D �cg c]  }|d   ‘Œ	 }}|D ]  }	d|	d   |	d   z
  c|	d<   |	d<   Œ |D �cg c]  }|d   ‘Œ	 }
}t        ||
«      D ];  \  }}t        ||z
  «      |kD  sŒd| j                  d   d<   d| j                  d   d<   Œ= |D �	cg c]  }	|	d   |	d   |	d   z
  dz  z   ‘Œ }}	|D �	cg c]  }	|	d   ‘Œ	 }}	t        j                  |D �	cg c]  }	|	d   ‘Œ	 c}	|D �	cg c]  }	|	d   ‘Œ	 c}	«      }| j                  �ro|D �	cg c]  }	|	d   ‘Œ	 }}	| j                  j                  «       j                  «       j                  j                   }t        j"                  ||«      }�n	| xj                  dz  c_        |D �cg c]  }|d   ‘Œ	 }}|D ]  }	d|	d   |	d   z
  c|	d<   |	d<   Œ |D �cg c]  }|d   ‘Œ	 }}t        ||«      D ];  \  }}t        ||z
  «      |kD  sŒd| j                  d   d<   d| j                  d   d<   Œ= |D �	cg c]  }	|	d   ‘Œ	 }}	|D �	cg c]  }	|	d   |	d   |	d   z
  dz  z   ‘Œ }}	t        j                  |D �	cg c]  }	|	d   ‘Œ	 c}	|D �	cg c]  }	|	d   ‘Œ	 c}	«      }t%        j&                  |||dj)                  | j*                  «      dj)                  | j*                  «      |d   d   t$        j,                  j/                  |d   d   t1        |d   d   ¬«      ¬«      ¬«      }	t        |	d   «      dkD  rG| xj                  d z  c_        | j                  j3                  |	«      f |�|| j                  d   d!<   y	y	| xj                  d"z  c_        t5        j6                  d#«       y	c c}w c c}w c c}w c c}w c c}w c c}w c c}	w c c}	w c c}	w c c}	w c c}	w c c}w c c}w c c}	w c c}	w c c}	w c c}	w )%a¡  Draw a collection of similar patches as a bar chart.

        After bars are sorted, an appropriate data dictionary must be created
        to tell plotly about this data. Just like draw_line or draw_markers,
        draw_bar translates patch/path information into something plotly
        understands.

        Positional arguments:
        patch_coll -- a collection of patches to be drawn as a bar chart.

        g»½×Ùß|Û=Úx1Úx0Úy1Úy0c              3   ó4   •K  — | ]  }‰d    ‰|   z
  –— Œ y­w©r   N© )Ú.0ÚiiiÚwidthss     €r   ú	<genexpr>z*PlotlyRenderer.draw_bar.<locals>.<genexpr>ç   s   øè ø€ ÒQ°s˜6 !™9 v¨c¡{Õ2ÑQùó   ƒc              3   ó4   •K  — | ]  }‰d    ‰|   z
  –— Œ y­wrx   ry   )rz   r{   Úheightss     €r   r}   z*PlotlyRenderer.draw_bar.<locals>.<genexpr>é   s   øè ø€ ÒM°#�G˜A‘J ¨¡Õ-ÑMùr~   c              3   ó:   •K  — | ]  }‰|d z      ‰|   kD  –— Œ y­w)r   Nry   )rz   r{   Úx_zeross     €r   r}   z*PlotlyRenderer.draw_bar.<locals>.<genexpr>ï   s#   øè ø€ ÒU°S�˜˜q™Ñ! G¨C¡LÕ0ÑUùs   ƒNéÿÿÿÿÚvÚhz,    Attempting to draw a vertical bar chart
r   Ústackr,   ÚbarmodeÚxr+   é   z.    Attempting to draw a horizontal bar chart
ÚyrD   r?   ÚalphaÚ	facecolorÚ	edgewidth)r(   )Úcolorr   )Úorientationrˆ   rŠ   r]   r^   ÚopacityÚmarkerr   z%    Heck yeah, I drew that bar chart
Úbargapz    Bar chart not drawn
zNfound box chart data with length <= 1, assuming data redundancy, not plotting.ry   )r   Úmake_barÚabsÚsumÚrangeÚlenÚallr   Úzipr   Úget_bar_gapr   r   Ú	get_xaxisÚget_major_formatterrS   r   Úmpl_dates_to_datestringsr   ÚBarrU   r   ÚbarÚMarkerÚdictÚ	add_traceÚwarningsÚwarn)r!   ÚcollÚtolrp   rq   ÚverticalÚ
horizontalr�   Úold_heightsrŸ   Únew_heightsÚoldÚnewrˆ   rŠ   Úbar_gapÚ	formatterÚ
old_rightsÚ
new_rightsr€   r|   r‚   s                      @@@r   rl   zPlotlyRenderer.draw_bar×   s  ú€ ð ˆØAEÖF°I”×"Ñ"Ñ/ YÓ/ÐFˆÐFØEJÖK¸	�)˜D‘/ I¨d¡OÓ3ÒKˆØFKÖL¸�9˜T‘? Y¨t¡_Ó4ÒLˆÜ”sÓQ¼eÄCÈÃKÓ>PÔQÓQÓRÐUXÑXˆä”ÓM¼¼sÀ7»|Ó9LÔMÓMÓNÐQTÑTð 	ñ ™
à8=Ö>¨9�y “Ò>ˆGÜÛU¼EÄ#ÀgÈcÈrÀlÓBSÓ<TÔUôð "‘à!‘ÙØ‰KàˆKØ˜#ÓØ�HŠHÐGÑG�HØ<AÖB¨y˜9 T›?ÐBˆKÐBØò @�Ø'(¨#¨d©)°c¸$±iÑ*?Ð$��D‘	˜3˜tš9ð@à<AÖB¨y˜9 T›?ÐBˆKÐBä ¨[Ó9ò A‘��SÜ�s˜S‘y“> CÓ'Ø;B�D—O‘O HÑ-¨iÑ8Ø=@�D—O‘O HÑ-¨kÒ:ðAð EJÖJ¸S��T‘˜c $™i¨#¨d©)Ñ3°qÑ8Ó8ÐJˆAÐJØ&+Ö,˜s��T“Ð,ˆAÐ,Ü×*Ñ*Ø&+Ö,˜s��T“Ò,ÀEÖ.J¸S¨s°4«yÒ.JóˆGð ×!Ó!Ø*/Ö0 3�S˜“YÐ0�Ð0à×'Ñ'×1Ñ1Ó3ß(Ñ(Ó*ß‘YŸx™xð ô
 ×5Ñ5°a¸ÓC’à�HŠHÐIÑI�HØ;@ÖA¨i˜) D›/ÐAˆJÐAØò @�Ø'(¨#¨d©)°c¸$±iÑ*?Ð$��D‘	˜3˜tš9ð@à;@ÖA¨i˜) D›/ÐAˆJÐAä 
¨JÓ7ò A‘��SÜ�s˜S‘y“> CÓ'Ø;B�D—O‘O HÑ-¨iÑ8Ø=@�D—O‘O HÑ-¨kÒ:ðAð ',Ö,˜s��T“Ð,ˆAÐ,ØDIÖJ¸S��T‘˜c $™i¨#¨d©)Ñ3°qÑ8Ó8ÐJˆAÐJÜ×*Ñ*Ø&+Ö,˜s��T“Ò,ÀEÖ.J¸S¨s°4«yÒ.JóˆGô �f‰fØ#ØØØ—-‘- §¡Ó-Ø—-‘- §¡Ó-Ø˜!‘H˜WÑ%Ü—6‘6—=‘=Ø˜A‘h˜{Ñ+Ü  a¡¨Ñ 5Ô6ð !ó ô
ˆô ˆs�3‰x‹=˜1ÒØ�HŠHÐ@Ñ@�HØ�O‰O×%Ñ% cÓ*Ñ+ØÐ"Ø6=�—‘ Ñ)¨(Ò3ð #ð �HŠHÐ3Ñ3�HÜ�M‰Mð:õùò_ GùÚKùÚLùò ?ùò Cùò Cùò KùÚ,ùâ,ùÒ.Jùò 1ùò Bùò Bùò -ùÚJùâ,ùÒ.Jsd   ŠR"¬R'ÁR,ÃR1Ä*R6ÅR;Æ3S ÇSÇ5S
ÈS
È+SÊ&SËSÌ/S#ÍS(Í1S-ÎS2
c                 óž  — |j                  d«      D �]²  }|d   d   d   }|d   d   d   }|dk(  �r|j                  d«      rð|j                  dd«      }|j                  d	«      }d}	d}
|}|}|d   j                  d
«      }|€|dk7  r| xj                  dz  c_         ydj	                  t        |d   |d   «      D ��cg c]  \  }}|› d|d   › d|d   › �‘Œ c}}«      }|dk(  rd}d}| dz  }	|dz  }
|dz  }||dz  z   }nd}t        j                  j                  d|dd|	|
||dd|||dœ|¤Ž}nb|dk(  rFd}|d   d   d   }|d   d   d   }t        j                  j                  d|dd||dz   ||dz   dœ|¤Ž}n| xj                  dz  c_         y| j                  j                  |«       | xj                  dz  c_        �Œµ yc c}}w )z³Create a shape that matches lines or markers in legends.

        Main issue is that path for circles do not render, so we have to use 'circle'
        instead of 'path'.
        ú+Údatar   r   ÚmarkersÚmarkerstyleÚsizeé   ÚsymbolÚ
markerpathNÚcirclez8not sure how to handle this marker without a valid path
ú ú,r‰   ÚpathÚpaperÚpixel)rP   ÚxrefÚyrefrt   rv   rs   ru   Ú	xsizemodeÚ	ysizemodeÚxanchorÚyanchorr½   Úlinesr   g{®Gáz”?)rP   rÀ   rÁ   rt   rv   rs   ru   z$not sure how to handle this element
z!    Heck yeah, I drew that shape
ry   )ÚsplitÚgetÚpopr   Újoinr™   r   r,   ÚShaper   Ú	add_shape)r!   ÚmodeÚshaper8   Úsingle_moderˆ   rŠ   r¶   r¸   rt   rv   rs   ru   r¹   Úar/   r½   Ú
shape_typeÚlegend_shapes                      r   Údraw_legend_shapesz!PlotlyRenderer.draw_legend_shapes8  sD  € ð  Ÿ:™: c›?ó E	=ˆKØ�f‘˜aÑ  Ñ#ˆAØ�f‘˜aÑ  Ñ#ˆAØ˜iÓ'¨E¯I©I°mÔ,DØ—y‘y ¨Ó+�ØŸ™ 8Ó,�à�Ø�Ø�Ø�Ø" =Ñ1×5Ñ5°lÓC�
ØÐ%¨&°HÒ*<Ø—H’HØSñ•Hñ à—x‘xÜ69¸*ÀQ¹-ÈÐTUÉÓ6W×X©d¨a°˜�s˜!˜A˜a™D˜6  1 Q¡4 &Ò)ÓXó�ð ˜XÒ%ð  �DØ!)�JØ˜ ™�BØ ™�BØ ™�BØ  q¡™‘Bð "(�JÜ!Ÿy™yŸ™ð  Ø#Ø Ø ØØØØØ%Ø%ØØØñ ð ñ ‘ð   Ò'Ø�Ø˜6‘] 1Ñ% aÑ(�Ø˜6‘] 1Ñ% aÑ(�ä!Ÿy™yŸ™ð 	 ØØ Ø ØØ˜4‘xØØ˜D‘yñ	 ð ñ	 ‘ð —’ÐCÑC•ÙØ�O‰O×%Ñ% lÔ3Ø�HŠHÐ<Ñ<�HñKE	=ùó& Ys   Ã G	c                 óä  — | xj                   dz  c_         i i i }}}|d   r|d   r| xj                   dz  c_         d}n9|d   r| xj                   dz  c_         d}n|d   r| xj                   dz  c_         d	}|d   r£t        j                  |d   d
   |d   d   «      }|d   dk(  rBt        j                  j                  ||d   d   t        j                  |d   d   «      ¬«      }n7t        t        ||d   d   t        j                  |d   d   «      ¬«      ¬«      }|d   rÁ|d   dk(  rgt        j                  j                  |d   d   |d   d   t        j                  |d   d   «      |d   d   t        |d   d   |d   d   ¬«      ¬«      }nRt        |d   d   |d   d   t        j                  |d   d   «      |d   d   t        |d   d   |d   d   ¬«      ¬«      }|d   dk(  �r1t        j                  t        |d   t        «      rt        |d   «      n|d   |d   D �cg c]  }|d   ‘Œ	 c}|d   D �cg c]  }|d   ‘Œ	 c}dj                  | j                  «      dj                  | j                  «      ||¬«      }| j                  rX| j                   j#                  «       j%                  «       j&                  j(                  }	t        j*                  |d    |	«      |d <   | j,                  j/                  |«      f | xj                   d!z  c_         y&|d   d"k(  r | j0                  d'|d#œ|¤Ž y&| xj                   d$z  c_         t3        j4                  d%«       y&c c}w c c}w )(a¨  Create a data dict for a line obj.

        This will draw 'lines', 'markers', or 'lines+markers'. For legend elements,
        this will use layout.shapes, so they can be positioned with paper refs.

        props.keys() -- [
        'coordinates',  ('data', 'axes', 'figure', or 'display')
        'data',         (a list of xy pairs)
        'mplobj',       (the matplotlib.lines.Line2D obj being rendered)
        'label',        (the name of the Line2D obj being rendered)
        'linestyle',    (linestyle dict, can be None, see below)
        'markerstyle',  (markerstyle dict, can be None, see below)
        ]

        props['linestyle'].keys() -- [
        'alpha',        (opacity of Line2D obj)
        'color',        (color of the line if it exists, not the marker)
        'linewidth',
        'dasharray',    (code for linestyle, see DASH_MAP in mpltools.py)
        'zorder',       (viewing precedence when stacked with other objects)
        ]

        props['markerstyle'].keys() -- [
        'alpha',        (opacity of Line2D obj)
        'marker',       (the mpl marker symbol, see SYMBOL_MAP in mpltools.py)
        'facecolor',    (color of the marker face)
        'edgecolor',    (color of the marker edge)
        'edgewidth',    (width of marker edge)
        'markerpath',   (an SVG path for drawing the specified marker)
        'zorder',       (viewing precedence when stacked with other objects)
        ]

        z    Attempting to draw a line Ú	linestylerµ   z... with both lines+markers
zlines+markersz... with just lines
rÆ   z... with just markers
r´   rŽ   r‹   Úcoordinatesr³   Ú	linewidthÚ	dasharray)rŽ   r(   Údash)r   rŒ   r‘   Ú
markersizeÚ	edgecolorr�   )rŽ   r(   )r�   rŽ   r¸   r¶   r   )r�   Ú	fillcolorr¸   r¶   r   Úlabelr   r   rD   r?   )rÍ   Únamerˆ   rŠ   r]   r^   r   r‘   rˆ   z     Heck yeah, I drew that line
Úaxes)rÍ   rÎ   z5    Line didn't have 'data' coordinates, not drawing
zeBummer! Plotly can currently only draw Line2D objects from matplotlib that are in 'data' coordinates!Nry   )r   r   Úmerge_color_and_opacityr   ÚscatterÚLineÚconvert_dashr¡   r    Úconvert_symbolÚScatterÚ
isinstanceÚstrrU   r   r   r   r›   rœ   rS   r   r�   r   r¢   rÓ   r£   r¤   )
r!   r8   r   r‘   rÎ   rÍ   rŽ   Úxy_pairÚmarked_liner®   s
             r   Údraw_marked_linezPlotlyRenderer.draw_marked_line…  s–  € ðD 	�ŠÐ4Ñ4�Ø  " b�eˆfˆØ�Ò %¨Ò"6Ø�HŠHÐ7Ñ7�HØ"‰DØ�;ÒØ�HŠHÐ/Ñ/�HØ‰DØ�=Ò!Ø�HŠHÐ1Ñ1�HØˆDØ�ÒÜ×4Ñ4Ø�kÑ" 7Ñ+¨U°;Ñ-?ÀÑ-HóˆEð �]Ñ# vÒ-Ü—z‘z—‘ØØ Ñ,¨[Ñ9Ü!×.Ñ.¨u°[Ñ/AÀ+Ñ/NÓOð 'ó ‘ô ÜØ#Ø# KÑ0°Ñ=Ü%×2Ñ2°5¸Ñ3EÀkÑ3RÓSôô�ð �ÒØ�]Ñ# vÒ-ÜŸ™×*Ñ*Ø! -Ñ0°Ñ9Ø Ñ.¨{Ñ;Ü#×2Ñ2°5¸Ñ3GÈÑ3QÓRØ˜}Ñ-¨lÑ;ÜØ# MÑ2°;Ñ?Ø# MÑ2°;Ñ?ôð +ó 	‘ô Ø! -Ñ0°Ñ9Ø# MÑ2°;Ñ?Ü#×2Ñ2°5¸Ñ3GÈÑ3QÓRØ˜}Ñ-¨lÑ;ÜØ# MÑ2°;Ñ?Ø# MÑ2°;Ñ?ôô	�ð �Ñ 6Ó)ÜŸ*™*Øô " %¨¡.´#Ô6ô ˜˜g™Ô'à˜w™à-2°6©]Ö; '�7˜1“:Ò;Ø-2°6©]Ö; '�7˜1“:Ò;Ø—m‘m D§L¡LÓ1Ø—m‘m D§L¡LÓ1ØØôˆKð ×!Ò!à×'Ñ'×1Ñ1Ó3ß(Ñ(Ó*ß‘YŸx™xð ô
 $,×#DÑ#DØ Ñ$ ió$�˜CÑ ð �O‰O×%Ñ% kÓ2Ñ3Ø�HŠHÐ;Ñ;ŽHØ�=Ñ! VÒ+à#ˆD×#Ñ#ÐD¨°UÑD¸eÓDà�HŠHÐSÑS�HÜ�M‰Mðõùò/ <ùÚ;s   È*M(È?M-c                 ó‚   — | xj                   dz  c_         | xj                   dz  c_         t        j                  d«       y)z3Draw image.

        Not implemented yet!

        z    Attempting to draw image
z    Not drawing image
zoAw. Snap! You're gonna have to hold off on the selfies for now. Plotly can't import images from matplotlib yet!N)r   r£   r¤   )r!   r8   s     r   Ú
draw_imagezPlotlyRenderer.draw_image  s3   € ð 	�ŠÐ4Ñ4�Ø�ŠÐ-Ñ-�Ü�‰ð*õ	
r   c                 ó"  — | xj                   dz  c_         |d   dk(  rHt        j                  |«      }d|d   d|ddœ}| xj                   dz  c_          | j                  d
i |¤Ž y| xj                   dz  c_         t	        j
                  d	«       y)ar  Add a path collection to data list as a scatter plot.

        Current implementation defaults such collections as scatter plots.
        Matplotlib supports collections that have many of the same parameters
        in common like color, size, path, etc. However, they needn't all be
        the same. Plotly does not currently support such functionality and
        therefore, the style for the first object is taken and used to define
        the remaining paths in the collection.

        props.keys() -- [
        'paths',                (structure: [vertices, path_code])
        'path_coordinates',     ('data', 'axes', 'figure', or 'display')
        'path_transforms',      (mpl transform, including Affine2D matrix)
        'offsets',              (offset from axes, helpful if in 'data')
        'offset_coordinates',   ('data', 'axes', 'figure', or 'display')
        'offset_order',
        'styles',               (style dict, see below)
        'mplobj'                (the collection obj being drawn)
        ]

        props['styles'].keys() -- [
        'linewidth',            (one or more linewidths)
        'facecolor',            (one or more facecolors for path)
        'edgecolor',            (one or more edgecolors for path)
        'alpha',                (one or more opacites for path)
        'zorder',               (precedence when stacked)
        ]

        z)    Attempting to draw a path collection
Úoffset_coordinatesr³   ÚoffsetsN)rÖ   r³   rÝ   rµ   rÕ   z'    Drawing path collection as markers
z6    Path collection not linked to 'data', not drawing
z¢Dang! That path collection is out of this world. I totally don't know what to do with it yet! Plotly can only import path collections linked to 'data' coordinatesry   )r   r   Úget_markerstyle_from_collectionrê   r£   r¤   )r!   r8   rµ   Úscatter_propss       r   Údraw_path_collectionz#PlotlyRenderer.draw_path_collection  s�   € ð< 	�ŠÐ@Ñ@�ØÐ%Ñ&¨&Ò0Ü"×BÑBÀ5ÓIˆKà%Ø˜iÑ(ØØ*Ø!ñˆMð �HŠHÐBÑB�HØ!ˆD×!Ñ!Ñ2 MÓ2à�HŠHÐTÑT�HÜ�M‰Mð;õr   c                 ó  — | xj                   dz  c_         t        j                  | j                  j                  fi |¤Ž}|r| xj
                  |gz  c_        y| xj                   dz  c_         t        j                  d«       y)a[  Draw path, currently only attempts to draw bar charts.

        This function attempts to sort a given path into a collection of
        horizontal or vertical bar charts. Most of the actual code takes
        place in functions from mpltools.py.

        props.keys() -- [
        'data',         (a list of verticies for the path)
        'coordinates',  ('data', 'axes', 'figure', or 'display')
        'pathcodes',    (code for the path, structure: ['M', 'L', 'Z', etc.])
        'style',        (style dict, see below)
        'mplobj'        (the mpl path object)
        ]

        props['style'].keys() -- [
        'alpha',        (opacity of path obj)
        'edgecolor',
        'facecolor',
        'edgewidth',
        'dasharray',    (style for path's enclosing line)
        'zorder'        (precedence of obj when stacked)
        ]

        z    Attempting to draw a path
z'    This path isn't a bar, not drawing
zJI found a path object that I don't think is part of a bar chart. Ignoring.N)r   r   Úis_barr   rR   r   r£   r¤   )r!   r8   rô   s      r   Ú	draw_pathzPlotlyRenderer.draw_pathB  sh   € ð2 	�ŠÐ5Ñ5�Ü—‘ ×!4Ñ!4×!?Ñ!?ÑIÀ5ÑIˆÙØ×Ò % Ñ(Öà�HŠHÐBÑB�HÜ�M‰Mð,õr   c                 ó¾  — | xj                   dz  c_         t        j                  |d   | j                  «      st	        j
                  d«       |d   j                  }|s|d   d   }d| j                  d   vrg | j                  d   d<   |d   d	k(  r(| xj                   d
z  c_          | j                  d(i |¤Ž y'|d   dk(  r(| xj                   dz  c_          | j                  d(i |¤Ž y'|d   dk(  r(| xj                   dz  c_          | j                  d(i |¤Ž y'| xj                   dz  c_         |d   dk7  r�| xj                   dz  c_         |d   j                  «       j                  |d   «      \  }}t        j                  ||| j                  d   «      \  }}d}d}|d   d   }	t        j                  |d   d   «      }
�na| xj                   dz  c_         |d   \  }}| j                  }| j                  d   dj!                  |«         }| j                  d   dj!                  |«         }|d   d   |cxk  r|d   d   k  rTn nQ|d   d   |cxk  r|d   d   k  r:n n7dj!                  | j                  «      }dj!                  | j                  «      }nh| xj                   dz  c_         |d   j                  «       j                  |d   «      \  }}t        j                  ||| j                  d   «      \  }}d}d}|d   d   }	t        j                  |d   d   «      }
t"        j$                  j'                  t)        |d   t*        «      rt+        |d   «      n|d   |d   d    ||||||	|
d!t"        j$                  j,                  j/                  |d   d"   |d   d#   ¬$«      ¬%«      }| j                  d   dxx   |fz  cc<   | xj                   d&z  c_         y'))aŽ  Create an annotation dict for a text obj.

        Currently, plotly uses either 'page' or 'data' to reference
        annotation locations. These refer to 'display' and 'data',
        respectively for the 'coordinates' key used in the Exporter.
        Appropriate measures are taken to transform text locations to
        reference one of these two options.

        props.keys() -- [
        'text',         (actual content string, not the text obj)
        'position',     (an x, y pair, not an mpl Bbox)
        'coordinates',  ('data', 'axes', 'figure', 'display')
        'text_type',    ('title', 'xlabel', or 'ylabel')
        'style',        (style dict, see below)
        'mplobj'        (actual mpl text object)
        ]

        props['style'].keys() -- [
        'alpha',        (opacity of text)
        'fontsize',     (size in points of text)
        'color',        (hex color)
        'halign',       (horizontal alignment, 'left', 'center', or 'right')
        'valign',       (vertical alignment, 'baseline', 'center', or 'top')
        'rotation',
        'zorder',       (precedence of text when stacked with other objs)
        ]

        z*    Attempting to draw an mpl text object
rj   aU  Looks like the annotation(s) you are trying 
to draw lies/lay outside the given figure size.

Therefore, the resulting Plotly figure may not be 
large enough to view the full text. To adjust 
the size of the figure, use the 'width' and 
'height' keys in the Layout object. Alternatively,
use the Margin object to adjust the figure's margins.ÚstyleÚhalignÚannotationsr,   Ú	text_typeÚxlabelz      Text object is an xlabel
Úylabelz      Text object is a ylabel
Útitlez      Text object is a title
z)      Text object is a normal annotation
rÖ   r³   z7        Text object isn't linked to 'data' coordinates
Úpositionr¾   Úvalignz4        Text object is linked to 'data' coordinates
rN   rO   r–   r   r   rD   r?   zL            Text object is outside plotting area, making 'paper' reference.
Útextr‹   FrŽ   Úfontsize©rŽ   r¶   )r   r�   rˆ   rŠ   rÀ   rÁ   ÚalignrÄ   rÅ   Ú	showarrowÚfontz&    Heck, yeah I drew that annotation
Nry   )r   r   Úcheck_cornersr   r£   r¤   Ú_multialignmentr   Údraw_xlabelÚdraw_ylabelÚ
draw_titleÚget_transformÚ	transformÚdisplay_to_paperÚ
convert_var   rU   r   r,   Ú
Annotationræ   rç   Ú
annotationÚFont)r!   r8   r  Úx_pxÚy_pxrˆ   rŠ   rÀ   rÁ   rÄ   rÅ   r   r]   r^   r  s                  r   Ú	draw_textzPlotlyRenderer.draw_textf  sØ  € ð: 	�ŠÐAÑA�Ü×%Ñ% e¨H¡o°t·|±|ÔDÜ�M‰MðHôð �h‘×/Ñ/ˆÙØ˜'‘N 8Ñ,ˆEØ §¡°Ñ 9Ñ9Ø79ˆD�O‰O˜HÑ% mÑ4Ø�Ñ Ò)Ø�HŠHÐ:Ñ:�HØˆD×ÑÑ%˜uÓ%Ø�;Ñ 8Ò+Ø�HŠHÐ9Ñ9�HØˆD×ÑÑ%˜uÓ%Ø�;Ñ 7Ò*Ø�HŠHÐ8Ñ8�HØˆD�O‰OÑ$˜eÓ$à�HŠHÐDÑD�HØ�]Ñ# vÒ-Ø—’ØQñ•ð ˜(‘O×1Ñ1Ó3×=Ñ=¸eÀJÑ>OÓPñ ��dô  ×0Ñ0°°t¸T¿_¹_ÈXÑ=VÓW‘��1Ø�Ø�Ø ™.¨Ñ2�Ü"×-Ñ-¨e°G©n¸XÑ.FÓG’à—’ÐVÑV•Ø˜ZÑ(‘��1ØŸ,™,�ØŸ™¨Ñ1°*×2CÑ2CÀGÓ2LÑM�ØŸ™¨Ñ1°*×2CÑ2CÀGÓ2LÑM�à˜'‘N 1Ñ%¨Ô=¨E°'©N¸1Ñ,=Õ=Ø˜g™ qÑ)¨AÔA°°g±¸qÑ0AÕAà!Ÿ=™=¨¯©Ó6�DØ!Ÿ=™=¨¯©Ó6‘Dà—H’HðEñ•Hð
 ˜h™×5Ñ5Ó7×AÑAÀ%È
ÑBSÓTñ �D˜$ô $×4Ñ4Ø˜d D§O¡O°HÑ$=ó‘D�A�qð #�DØ"�DØ ™.¨Ñ2�Ü"×-Ñ-¨e°G©n¸XÑ.FÓG�ÜŸ™×-Ñ-ô " %¨¡-´Ô5ô ˜˜f™Ô&à˜v™à˜g™ wÑ/ØØØØØØØØÜ—Y‘Y×)Ñ)×.Ñ.Ø ™.¨Ñ1¸¸g¹ÀzÑ8Rð /ó ð .ó ˆJð& �O‰O˜HÑ% mÓ4¸¸ÑEÓ4Ø�HŠHÐAÑAŽHr   c                 óÜ  — | xj                   dz  c_         t        | j                  j                  «      dkD  rà| xj                   dz  c_         |d   j	                  «       j                  |d   «      \  }}t        j                  ||| j                  d   «      \  }}t        j                  j                  |d   t        j                  j                  j                  |d   d	   |d   d
   ¬«      dd||ddd¬«	      }| j                  d   dxx   |fz  cc<   y| xj                   dz  c_         |d   | j                  d   d<   t        |d   d
   |d   d	   ¬«      }|| j                  d   d<   y)aÖ  Add a title to the current subplot in layout dictionary.

        If there exists more than a single plot in the figure, titles revert
        to 'page'-referenced annotations.

        props.keys() -- [
        'text',         (actual content string, not the text obj)
        'position',     (an x, y pair, not an mpl Bbox)
        'coordinates',  ('data', 'axes', 'figure', 'display')
        'text_type',    ('title', 'xlabel', or 'ylabel')
        'style',        (style dict, see below)
        'mplobj'        (actual mpl text object)
        ]

        props['style'].keys() -- [
        'alpha',        (opacity of text)
        'fontsize',     (size in points of text)
        'color',        (hex color)
        'halign',       (horizontal alignment, 'left', 'center', or 'right')
        'valign',       (vertical alignment, 'baseline', 'center', or 'top')
        'rotation',
        'zorder',       (precedence of text when stacked with other objs)
        ]

        z#        Attempting to draw a title
r   z<          More than one subplot, adding title as annotation
rj   rþ   r,   r   r÷   rŽ   r  r  r¾   ÚcenterrH   F)	r   r  rÀ   rÁ   rˆ   rŠ   rÄ   rÅ   r  rù   z;          Only one subplot found, adding as a plotly title
rý   ©r¶   rŽ   Ú
title_fontN)r   r—   r   rß   r  r  r   r  r   r   r,   r  r  r  r¡   )r!   r8   r  r  rˆ   rŠ   r  r  s           r   r
  zPlotlyRenderer.draw_titleÛ  sm  € ð4 	�ŠÐ:Ñ:�Üˆt�|‰|× Ñ Ó! AÒ%Ø�HŠHØRñ�Hð ˜x™×6Ñ6Ó8×BÑBÀ5ÈÑCTÓU‰JˆD�$Ü×,Ñ,¨T°4¸¿¹ÈÑ9RÓS‰DˆAˆqÜŸ™×-Ñ-Ø˜6‘]Ü—Y‘Y×)Ñ)×.Ñ.Ø ™.¨Ñ1¸¸g¹ÀzÑ8Rð /ó ð ØØØØ Ø Øð .ó ˆJð �O‰O˜HÑ% mÓ4¸¸ÑEÔ4à�HŠHØQñ�Hð 27°v±ˆD�O‰O˜HÑ% gÑ.ÜØ˜7‘^ JÑ/°u¸W±~ÀgÑ7NôˆJð 7AˆD�O‰O˜HÑ% lÒ3r   c                 ó  — | xj                   dz  c_         dj                  | j                  «      }t        |d   «      | j                  d   |   d<   t        |d   d   |d   d   ¬	«      }|| j                  d   |   d
<   y)ae  Add an xaxis label to the current subplot in layout dictionary.

        props.keys() -- [
        'text',         (actual content string, not the text obj)
        'position',     (an x, y pair, not an mpl Bbox)
        'coordinates',  ('data', 'axes', 'figure', 'display')
        'text_type',    ('title', 'xlabel', or 'ylabel')
        'style',        (style dict, see below)
        'mplobj'        (actual mpl text object)
        ]

        props['style'].keys() -- [
        'alpha',        (opacity of text)
        'fontsize',     (size in points of text)
        'color',        (hex color)
        'halign',       (horizontal alignment, 'left', 'center', or 'right')
        'valign',       (vertical alignment, 'baseline', 'center', or 'top')
        'rotation',
        'zorder',       (precedence of text when stacked with other objs)
        ]

        z        Adding xlabel
rN   r   r,   rý   r÷   r  rŽ   r  r  N)r   rU   r   rç   r   r¡   ©r!   r8   Úaxis_keyr  s       r   r  zPlotlyRenderer.draw_xlabel  s„   € ð. 	�ŠÐ-Ñ-�Ø×$Ñ$ T§\¡\Ó2ˆÜ7:¸5À¹=Ó7Iˆ�‰˜Ñ! (Ñ+¨GÑ4ÜØ�w‘ 
Ñ+°5¸±>À'Ñ3Jô
ˆ
ð =Gˆ�‰˜Ñ! (Ñ+¨LÒ9r   c                 óð   — | xj                   dz  c_         dj                  | j                  «      }|d   | j                  d   |   d<   t	        |d   d   |d   d   ¬	«      }|| j                  d   |   d
<   y)ad  Add a yaxis label to the current subplot in layout dictionary.

        props.keys() -- [
        'text',         (actual content string, not the text obj)
        'position',     (an x, y pair, not an mpl Bbox)
        'coordinates',  ('data', 'axes', 'figure', 'display')
        'text_type',    ('title', 'xlabel', or 'ylabel')
        'style',        (style dict, see below)
        'mplobj'        (actual mpl text object)
        ]

        props['style'].keys() -- [
        'alpha',        (opacity of text)
        'fontsize',     (size in points of text)
        'color',        (hex color)
        'halign',       (horizontal alignment, 'left', 'center', or 'right')
        'valign',       (vertical alignment, 'baseline', 'center', or 'top')
        'rotation',
        'zorder',       (precedence of text when stacked with other objs)
        ]

        z        Adding ylabel
rO   r   r,   rý   r÷   r  rŽ   r  r  N)r   rU   r   r   r¡   r  s       r   r	  zPlotlyRenderer.draw_ylabel3  s   € ð. 	�ŠÐ-Ñ-�Ø×$Ñ$ T§\¡\Ó2ˆØ7<¸V±}ˆ�‰˜Ñ! (Ñ+¨GÑ4ÜØ�w‘ 
Ñ+°5¸±>À'Ñ3Jô
ˆ
ð =Gˆ�‰˜Ñ! (Ñ+¨LÒ9r   c                 óˆ   — | xj                   dz  c_         dD ]  }	 | j                  d   |= Œ y# t        t        f$ r Y Œ(w xY w)aI  Revert figure layout to allow plotly to resize.

        By default, PlotlyRenderer tries its hardest to precisely mimic an
        mpl figure. However, plotly is pretty good with aesthetics. By
        running PlotlyRenderer.resize(), layout parameters are deleted. This
        lets plotly choose them instead of mpl.

        z+Resizing figure, deleting keys from layout
)r(   r)   r*   r2   r,   N)r   r   ÚKeyErrorÚAttributeError)r!   Úkeys     r   ÚresizezPlotlyRenderer.resizeR  sQ   € ð 	�ŠÐBÑB�Ø<ò 	ˆCðØ—O‘O HÑ-¨cÑ2ñ	øô œnÐ-ò Ùðús   œ/¯AÁ Ac                 ó.   — | xj                   dz  c_         y )Nz+Stripping mpl style is no longer supported
)r   r    s    r   Ústrip_stylezPlotlyRenderer.strip_styleb  s   € Ø�ŠÐBÑBŽr   N)r   Ú
__module__Ú__qualname__Ú__doc__r"   r9   r<   re   rh   rg   rl   rÓ   rê   rì   rò   rõ   r  r
  r  r	  r!  r#  ry   r   r   r   r      st   „ ñò$2ò( 5òD'ò E&òN#ò !ò_òBK=òZzòx
ò1òf"òHsBòj7AòrGò>Gò>ó Cr   r   )NN)r&  r£   Úplotly.graph_objsÚ
graph_objsr   Úplotly.matplotlylib.mplexporterr   Úplotly.matplotlylibr   r   Úformatwarningr   ry   r   r   ú<module>r,     s8   ðñó å Ý 4Ý (óOð -€Ô ôKC�Xõ KCr   