
    6Dh                     b    S r SSKrSSKJr  SSKJr  SSKJr  SS jr	\	\l
         " S S\5      rg)	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                 :    U< SU< SUR                   < SU < S3$ )N:z: z:

z

)__name__)msgcategoryfilenamelinenofilelines         N/var/www/html/env/lib/python3.13/site-packages/plotly/matplotlylib/renderer.pywarning_on_one_liner      s    %-vx7H7H#NN    c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rSrg)PlotlyRenderer   a  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                     [         R                  " 5       U l        SU l        SU l        SU l        / U l        SU l        SU l        SU l	        SU l
        SU l        g)zInitialize 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__PlotlyRenderer.__init__,   sV     ))+"""""1r   c           
         U =R                   S-  sl         Xl        [        R                  " [	        US   US   -  5      [	        US   US   -  5      SSS9U R
                  S'   [        R                  " U5      u  U l        U l	        [        R                  R                  [	        U R                  S	   U R
                  S   S
   -  5      [	        SU R                  S   -
  U R
                  S   S
   -  5      [	        SU R                  S   -
  U R
                  S   S   -  5      [	        U R                  S	   U R
                  S   S   -  5      S	S9nX0R
                  S   S'   g)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propsr4   s       r   open_figurePlotlyRenderer.open_figure@   sO     	&&$&IIeJ'%,67u[)E%L89	%
! 08/G/G/L,4,!!$##A&)B7)KKL1t((++tx/H/QQR1t((++tx/H/RRS$##A&)B8)LLM " 
 /5!(+r   c                 R    SU R                   S   S'   U =R                  S-  sl        g)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"   r9   s     r   close_figurePlotlyRenderer.close_figureb   s&     38!,/&&r   c                    U =R                   S-  sl         Xl        UR                   Vs/ s H!  nUR                  R                  S:X  d  M  UPM#     snU l        / U l        U =R                  S-  sl        [        R                  R                  SR                  U R                  5      SSS9n[        R                  R                  SR                  U R                  5      SSS9n[        R                  " XU R                  U R                   S	9u  pgUR#                  U5        UR#                  U5        [        R$                  " US
5      n[        R$                  " US5      n	[        R$                  " US5      n
[        R$                  " US5      n[        R&                  " X5      US'   [        R&                  " X5      US'   XS'   XS'   X@R(                  S   SR                  U R                  5      '   XPR(                  S   SR                  U R                  5      '   S[+        U5      ;   a  US   S:X  a  SU l        gggs  snf )as  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})axr:   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"   rI   r:   cxaxisyaxis	mpl_xaxis	mpl_yaxisbottom_spine	top_spine
left_spineright_spines               r   	open_axesPlotlyRenderer.open_axesr   s   > 	&&  ]]
"{{##~5 "

 		==.h   
 		==.h   
  (44):):TEVEV 
	 	YY11"h?..r59	//F;
00W="22<Kh"22:Kh(j%j FK!*"3"3DLL"ABEJ!*"3"3DLL"AB SZE&MV$;!%D %<G
s   I I c                 r    U R                  U R                  5        U =R                  S-  sl        SU l        g)aH  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"   rI   s     r   
close_axesPlotlyRenderer.close_axes   s-     	t(()&&"r   c                     / nU R                    H:  nUR                  U R                   Vs/ s H  nUS   U;   d  M  UPM     sn5        M<     U H  nU R                  U5        M     g s  snf )Nmplobj)r   appendr   draw_bar)r"   bars
mpl_traces	container	bar_propstraces         r   rl   PlotlyRenderer.draw_bars   st     
,,I &*%6%6%6	 *i7 %6 -  EMM%   s
   A(
A(
c                 v
  ^^^ SnU Vs/ s H  n[         R                  " S$0 UD6PM     nnU Vs/ s H  o3S   US   -
  PM     snmU Vs/ s H  o3S   US   -
  PM     snm[        [        U4S j[	        [        T5      5       5       5      5      U:  n[        [        U4S j[	        [        T5      5       5       5      5      U:  nU(       aQ  U(       aJ  U Vs/ s H  o3S   PM	     snm[        U4S j[	        [        TS	S
 5      5       5       5      (       a  SnOSnOU(       a  SnOSnUS:X  Ga  U =R                  S-  sl        U Vs/ s H  o3S   PM	     nnU H  n	SU	S   U	S   -
  sU	S'   U	S'   M     U Vs/ s H  o3S   PM	     n
n[        X5       H<  u  p[        X-
  5      U:  d  M  SU R                  S   S'   SU R                  S   S'   M>     U V	s/ s H  oS   U	S   U	S   -
  S-  -   PM     nn	U V	s/ s H  oS   PM	     nn	[         R                  " U V	s/ s H  oS   PM	     sn	U V	s/ s H  oS   PM	     sn	5      nU R                  (       ag  U V	s/ s H  oS   PM	     nn	U R                  R                  5       R                  5       R                  R                   n[         R"                  " UU5      nGOU =R                  S-  sl        U Vs/ s H  o3S   PM	     nnU H  n	SU	S   U	S   -
  sU	S'   U	S'   M     U Vs/ s H  o3S   PM	     nn[        UU5       H<  u  p[        X-
  5      U:  d  M  SU R                  S   S'   SU R                  S   S'   M>     U V	s/ s H  oS   PM	     nn	U V	s/ s H  oS   U	S   U	S   -
  S-  -   PM     nn	[         R                  " U V	s/ s H  oS   PM	     sn	U V	s/ s H  oS   PM	     sn	5      n[$        R&                  " UUUSR)                  U R*                  5      SR)                  U R*                  5      US   S   [$        R,                  R/                  US   S   [1        US   S   S9S9S9n	[        U	S   5      S:  aG  U =R                  S -  sl        U R                  R3                  U	5      4  Ub  XR                  S   S!'   g	g	U =R                  S"-  sl        [4        R6                  " S#5        g	s  snf s  snf s  snf s  snf s  snf s  snf s  sn	f s  sn	f s  sn	f s  sn	f s  sn	f s  snf s  snf s  sn	f s  sn	f s  sn	f s  sn	f )%ai  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   :   >#    U  H  nTS    TU   -
  v   M     g7fr   N ).0iiiwidthss     r   	<genexpr>*PlotlyRenderer.draw_bar.<locals>.<genexpr>   s      Q>Ps6!9vc{2>P   c              3   :   >#    U  H  nTS    TU   -
  v   M     g7fr   r   )r   r   heightss     r   r   r      s      M9L#GAJ-9Lr   c              3   @   >#    U  H  nTUS -      TU   :  v   M     g7f)r   Nr   )r   r   x_zeross     r   r   r      s%     U<TSq!GCL0<Ts   Nvhz,    Attempting to draw a vertical bar chart
r   stackr.   barmodexr-      z.    Attempting to draw a horizontal bar chart
yrH   rC   alpha	facecolor	edgewidth)r*   )colorr   )orientationr   r   ra   rb   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.r   )r   make_barabssumrangelenallr   zipr   get_bar_gapr   r   	get_xaxisget_major_formatterrW   r   mpl_dates_to_datestringsr   BarrY   r   barMarkerdict	add_tracewarningswarn)r"   colltolrv   rw   vertical
horizontalr   old_heightsr   new_heightsoldnewr   r   bar_gap	formatter
old_rights
new_rightsr   r   r   s                      @@@r   rr   PlotlyRenderer.draw_bar   s     AEFI""/Y/FEJKU	D/IdO3UKFKLeT?Yt_4eLsQeCK>PQQRUXXMs7|9LMMNQTT 	 
8=>9>GUE#gcrlBS<TU  "!KK#HHGGH<ABEyT?EKB'(#d)c$i*?$D	3t9 <ABEyT?EKB9sy>C';BDOOH-i8=@DOOH-k: : EJJESTc$i#d)3q88EAJ&+,esTeA,**&+,esTe,E.JES4yE.JG !!*/0%3Y%0''113((*Yxx 
 55aCHHIIH;@A5iD/5JA'(#d)c$i*?$D	3t9 ;@A5iD/5JA
J7sy>C';BDOOH-i8=@DOOH-k: 8 ',,esTeA,DIJESTc$i#d)3q88EAJ**&+,esTe,E.JES4yE.JG ff#------!HW%66==Ah{+a 56 ! 
 s3x=1HH@@HOO%%c*+"6=)(3 # HH33HMM:_ GKL ? C C K,,.J 1 B B -J,.Jsd    S&S+S0S5S:=S?T?T	#T7T
!TTT"0T'T,7T1T6
c                    UR                  S5       GH  nUS   S   S   nUS   S   S   nUS:X  Ga  UR                  S5      (       a  UR                  SS5      nUR                  S	5      nSn	Sn
UnUnUS   R                  S
5      nUc  US:w  a  U =R                  S-  sl          gSR	                  [        US   US   5       VVs/ s H  u  pU SUS    SUS    3PM     snn5      nUS:X  a  SnSnU* S-  n	US-  n
US-  nXwS-  -   nOSn[        R                  R                  " SUSSU	U
UUSSUUUS.UD6nOdUS:X  aG  SnUS   S   S   nUS   S   S   n[        R                  R                  " SUSSUUS-   UUS-   S.UD6nOU =R                  S-  sl          gU R                  R                  U5        U =R                  S-  sl        GM     gs  snnf )zCreate 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)rT   xrefyrefr{   r}   rz   r|   	xsizemode	ysizemodexanchoryanchorr   linesr   g{Gz?)rT   r   r   r{   r}   rz   r|   z$not sure how to handle this element
z!    Heck yeah, I drew that shape
r   )splitgetpopr   joinr   r   r.   Shaper   	add_shape)r"   modeshaper:   single_moder   r   r   r   r{   r}   rz   r|   r   ar1   r   
shape_typelegend_shapes                      r   draw_legend_shapes!PlotlyRenderer.draw_legend_shapes9  sD     ::c?Kfa #Afa #Ai'EIIm,D,Dyy+8,"=155lC
%&H*<HHSH xx69*Q-TU6WX6Wdas!AaD61Q4&)6WX X%  D!)JBBBqB "(J!yy  #  %%     '6]1%a(6]1%a(!yy 	   4xDy	  	  CCOO%%l3HH<<HHK +& Ys   Gc                 "   U =R                   S-  sl         0 0 0 pCnUS   (       a"  US   (       a  U =R                   S-  sl         SnOCUS   (       a  U =R                   S-  sl         SnO!US   (       a  U =R                   S-  sl         S	nUS   (       a  [        R                  " US   S
   US   S   5      nUS   S:X  a@  [        R                  R                  UUS   S   [        R                  " US   S   5      S9nO2[        [        UUS   S   [        R                  " US   S   5      S9S9nUS   (       a  US   S:X  ab  [        R                  R                  US   S   US   S   [        R                  " US   S   5      US   S   [        US   S   US   S   S9S9nOM[        US   S   US   S   [        R                  " US   S   5      US   S   [        US   S   US   S   S9S9nUS   S:X  Ga>  [        R                  " W[        US   [        5      (       a  [        US   5      OUS   US    Vs/ s H  owS   PM	     snUS    Vs/ s H  owS   PM	     snSR                  U R                  5      SR                  U R                  5      UUS9nU R                  (       aY  U R                   R#                  5       R%                  5       R&                  R(                  n	[        R*                  " US    U	5      US '   U R,                  R/                  U5      4  U =R                   S!-  sl         g&US   S":X  a  U R0                  " S'WUS#.UD6  g&U =R                   S$-  sl         [2        R4                  " S%5        g&s  snf s  snf )(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   rH   rC   )r   namer   r   ra   rb   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!Nr   )r   r   merge_color_and_opacityr   scatterLineconvert_dashr   r   convert_symbolScatter
isinstancestrrY   r   r   r   r   r   rW   r   r   r   r   r   r   r   )
r"   r:   r   r   r   r   r   xy_pairmarked_liner   s
             r   draw_marked_linePlotlyRenderer.draw_marked_line  s   D 	44 "be%"6HH77H"D;HH//HD=!HH11HD44k"7+U;-?-HE ]#v-zz,[9!..u[/A+/NO '  ##K0=%2253Ek3RS ]#v-**!-09.{;#2253G3QR}-l;#M2;?#M2;? + 	 !-09#M2;?#2253G3QR}-l;#M2;?#M2;?	 6)** "%.#66 g'w-26];]'1:];-26];]'1:];mmDLL1mmDLL1K !!''113((*Yxx 
 $,#D#D$i$C  OO%%k23HH;;H=!V+##DUDeDHHSSHMM/ <;s    NNc                     U =R                   S-  sl         U =R                   S-  sl         [        R                  " S5        g)z#Draw 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"   r:   s     r   
draw_imagePlotlyRenderer.draw_image  s3     	44--*	
r   c                 (   U =R                   S-  sl         US   S:X  aI  [        R                  " U5      nSUS   SUSS.nU =R                   S-  sl         U R                  " S
0 UD6  gU =R                   S-  sl         [        R
                  " S	5        g)a  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
zDang! 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' coordinatesr   )r   r   get_markerstyle_from_collectionr   r   r   )r"   r:   r   scatter_propss       r   draw_path_collection#PlotlyRenderer.draw_path_collection  s    < 	@@%&&0"BB5IK%i(*!M HHBBH!!2M2HHTTHMM;r   c                    U =R                   S-  sl         [        R                  " U R                  R                  40 UD6nU(       a  U =R
                  U/-  sl        gU =R                   S-  sl         [        R                  " S5        g)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   rV   r   r   r   )r"   r:   r  s      r   	draw_pathPlotlyRenderer.draw_pathC  sh    2 	55!4!4!?!?I5I%(HHBBHMM,r   c                    U =R                   S-  sl         [        R                  " US   U R                  5      (       d  [        R
                  " S5        US   R                  nU(       d  US   S   nSU R                  S   ;  a  / U R                  S   S'   US   S	:X  a(  U =R                   S
-  sl         U R                  " S(0 UD6  g'US   S:X  a(  U =R                   S-  sl         U R                  " S(0 UD6  g'US   S:X  a(  U =R                   S-  sl         U R                  " S(0 UD6  g'U =R                   S-  sl         US   S:w  a  U =R                   S-  sl         US   R                  5       R                  US   5      u  p4[        R                  " X4U R                  S   5      u  pVSnSnUS   S   n	[        R                  " US   S   5      n
GOcU =R                   S-  sl         US   u  pVU R                  nU R                  S   SR!                  U5         nU R                  S   SR!                  U5         nUS   S   Us=:  a  US   S   :  aV  O  OSUS   S   Us=:  a  US   S   :  a:  O  O7SR!                  U R                  5      nSR!                  U R                  5      nOfU =R                   S-  sl         US   R                  5       R                  US   5      u  p4[        R                  " X4U R                  S   5      u  pVSnSnUS   S   n	[        R                  " US   S   5      n
["        R$                  R'                  [)        US   [*        5      (       a  [+        US   5      OUS   US   S    UUUUUU	U
S!["        R$                  R,                  R/                  US   S"   US   S#   S$9S%9nU R                  S   S==   U4-  ss'   U =R                   S&-  sl         g'))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
rp   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
rR   rS   r   r   r   rH   rC   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
Nr   )r   r   check_cornersr   r   r   _multialignmentr   draw_xlabeldraw_ylabel
draw_titleget_transform	transformdisplay_to_paper
convert_var   rY   r   r.   
Annotationr   r   
annotationFont)r"   r:   r  x_pxy_pxr   r   r   r   r   r   r   ra   rb   r  s                  r   	draw_textPlotlyRenderer.draw_textg  s   : 	AA%%eHot||DDMMH h//'N8,E 9979DOOH%m4)HH::H%u%;8+HH99H%u%;7*HH88HOO$e$HHDDH]#v-Q (O113==eJ>OP   00T__X=VW.2"--eGnX.FGVVZ(,,1*2C2CG2LM1*2C2CG2LM'N1%=E'N1,==gq)AAgq0AA!==6D!==6DHHEH
 h557AA%
BST D $44DOOH$=DA #D"D.2"--eGnX.FG-- "%-55 f&vgw/YY))...1gz8R /  . J& OOH%m4E4HHAAHr   c                    U =R                   S-  sl         [        U R                  R                  5      S:  a  U =R                   S-  sl         US   R	                  5       R                  US   5      u  p#[        R                  " X#U R                  S   5      u  pE[        R                  R                  US   [        R                  R                  R                  US   S	   US   S
   S9SSUUSSSS9	nU R                  S   S==   U4-  ss'   gU =R                   S-  sl         US   U R                  S   S'   [        US   S
   US   S	   S9nXpR                  S   S'   g)a6  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
rp   r  r.   r  r  r   r  r  r   centerrL   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"   r:   r   r!  r   r   r  r'  s           r   r  PlotlyRenderer.draw_title  se   4 	::t||  !A%HHRH x668BB5CTUJD,,T9RSDA--6]YY))...1gz8R /     . J OOH%m4E4HHQH 27vDOOH%g.7^J/uW~g7NJ 7AOOH%l3r   c                     U =R                   S-  sl         SR                  U R                  5      n[        US   5      U R                  S   U   S'   [        US   S   US   S   S	9nX0R                  S   U   S
'   g)a  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
rR   r  r.   r  r  r  r   r&  r'  N)r   rY   r   r   r   r   r"   r:   axis_keyr'  s       r   r  PlotlyRenderer.draw_xlabel  s    . 	--$$T\\27:5=7I!(+G4w
+5>'3J

 =G!(+L9r   c                     U =R                   S-  sl         SR                  U R                  5      nUS   U R                  S   U   S'   [	        US   S   US   S   S	9nX0R                  S   U   S
'   g)a  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
rS   r  r.   r  r  r  r   r&  r'  N)r   rY   r   r   r   r*  s       r   r  PlotlyRenderer.draw_ylabel4  s}    . 	--$$T\\27<V}!(+G4w
+5>'3J

 =G!(+L9r   c                     U =R                   S-  sl         S H  n U R                  S   U	 M     g! [        [        4 a     M,  f = f)a!  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,   r4   r.   N)r   r   KeyErrorAttributeError)r"   keys     r   resizePlotlyRenderer.resizeS  sL     	BB<COOH-c2 = n- s   1AAc                 .    U =R                   S-  sl         g )Nz+Stripping mpl style is no longer supported
)r   r!   s    r   strip_stylePlotlyRenderer.strip_stylec  s    BBr   )
r   r   r   r   r   r   r    r   r   r   N)r   
__module____qualname____firstlineno____doc__r#   r;   r?   ri   rm   rl   rr   r   r   r   r   r  r"  r  r  r  r3  r6  __static_attributes__r   r   r   r   r      st    $2( 5D' 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   r   r   r   <module>rB     s8      4 (O - KCX KCr   