class_docstr: 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
docstr: 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)
  ]
docstr_tok: ["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",")","]"]
code: def draw_text(self, **props):
      """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)
      ]
  
      """
      self.msg += "    Attempting to draw an mpl text object\n"
      if not mpltools.check_corners(props["mplobj"], self.mpl_fig):
          warnings.warn(
              "Looks like the annotation(s) you are trying \n"
              "to draw lies/lay outside the given figure size.\n\n"
              "Therefore, the resulting Plotly figure may not be \n"
              "large enough to view the full text. To adjust \n"
              "the size of the figure, use the 'width' and \n"
              "'height' keys in the Layout object. Alternatively,\n"
              "use the Margin object to adjust the figure's margins."
          )
      align = props["mplobj"]._multialignment
      if not align:
          align = props["style"]["halign"]  # mpl default
      if "annotations" not in self.plotly_fig["layout"]:
          self.plotly_fig["layout"]["annotations"] = []
      if props["text_type"] == "xlabel":
          self.msg += "      Text object is an xlabel\n"
          self.draw_xlabel(**props)
      elif props["text_type"] == "ylabel":
          self.msg += "      Text object is a ylabel\n"
          self.draw_ylabel(**props)
      elif props["text_type"] == "title":
          self.msg += "      Text object is a title\n"
          self.draw_title(**props)
      else:  # just a regular text annotation...
          self.msg += "      Text object is a normal annotation\n"
          if props["coordinates"] != "data":
              self.msg += (
                  "        Text object isn't linked to 'data' "
                  "coordinates\n"
              )
              x_px, y_px = (
                  props["mplobj"]
                  .get_transform()
                  .transform(props["position"])
              )
              x, y = mpltools.display_to_paper(
                  x_px, y_px, self.plotly_fig["layout"]
              )
              xref = "paper"
              yref = "paper"
              xanchor = props["style"]["halign"]  # no difference here!
              yanchor = mpltools.convert_va(props["style"]["valign"])
          else:
              self.msg += (
                  "        Text object is linked to 'data' "
                  "coordinates\n"
              )
              x, y = props["position"]
              axis_ct = self.axis_ct
              xaxis = self.plotly_fig["layout"][
                  "xaxis{0}".format(axis_ct or "")
              ]
              yaxis = self.plotly_fig["layout"][
                  "yaxis{0}".format(axis_ct or "")
              ]
              if (
                  xaxis["range"][0] < x < xaxis["range"][1]
                  and yaxis["range"][0] < y < yaxis["range"][1]
              ):
                  xref = "x{0}".format(self.axis_ct)
                  yref = "y{0}".format(self.axis_ct)
              else:
                  self.msg += (
                      "            Text object is outside "
                      "plotting area, making 'paper' reference.\n"
                  )
                  x_px, y_px = (
                      props["mplobj"]
                      .get_transform()
                      .transform(props["position"])
                  )
                  x, y = mpltools.display_to_paper(
                      x_px, y_px, self.plotly_fig["layout"]
                  )
                  xref = "paper"
                  yref = "paper"
              xanchor = props["style"]["halign"]  # no difference here!
              yanchor = mpltools.convert_va(props["style"]["valign"])
          annotation = dict(
              text=(
                  str(props["text"])
                  if isinstance(props["text"], six.string_types)
                  else props["text"]
              ),
              opacity=props["style"]["alpha"],
              x=x,
              y=y,
              xref=xref,
              yref=yref,
              align=align,
              xanchor=xanchor,
              yanchor=yanchor,
              showarrow=False,  # change this later?
              font=dict(
                  color=props["style"]["color"],
                  size=props["style"]["fontsize"],
              ),
          )
          self.plotly_fig["layout"]["annotations"] += (annotation,)
          self.msg += "    Heck, yeah I drew that annotation\n"
  
imports: from __future__ import absolute_import
  import six
  import warnings
  from .mplexporter import Renderer
  from .None import mpltools
label_desc: Use image node_id 12 for calling the PlotlyRenderer obj's underlying member method code with example usage: obj.draw_text() without return types