def __init__(self, data, obj):
        """Returns the PGFPlots code for an axis environment.
        """
        self.content = []

        # Are we dealing with an axis that hosts a colorbar? Skip then, those are
        # treated implicitily by the associated axis.
        self.is_colorbar = _is_colorbar_heuristic(obj)
        if self.is_colorbar:
            return

        # instantiation
        self.nsubplots = 1
        self.subplot_index = 0
        self.is_subplot = False

        if isinstance(obj, mpl.axes.Subplot):
            self._subplot(obj, data)

        self.axis_options = []

        # check if axes need to be displayed at all
        if not obj.axison:
            self.axis_options.append("hide x axis")
            self.axis_options.append("hide y axis")

        # get plot title
        title = obj.get_title()
        data["current axis title"] = title
        if title:
            self.axis_options.append(u"title={{{}}}".format(title))

        # get axes titles
        xlabel = obj.get_xlabel()
        if xlabel:
            xlabel = mpl_backend_pgf.common_texification(xlabel)
            self.axis_options.append(u"xlabel={{{}}}".format(xlabel))
        ylabel = obj.get_ylabel()
        if ylabel:
            ylabel = mpl_backend_pgf.common_texification(ylabel)
            self.axis_options.append(u"ylabel={{{}}}".format(ylabel))

        # Axes limits.
        # Sort the limits so make sure that the smaller of the two is actually *min.
        ff = data["float format"]
        xlim = sorted(list(obj.get_xlim()))
        self.axis_options.append(("xmin=" + ff + ", xmax=" + ff).format(*xlim))
        ylim = sorted(list(obj.get_ylim()))
        self.axis_options.append(("ymin=" + ff + ", ymax=" + ff).format(*ylim))

        # axes scaling
        if obj.get_xscale() == "log":
            self.axis_options.append("xmode=log")
            self.axis_options.append(
                "log basis x={{{}}}".format(_try_f2i(obj.xaxis._scale.base))
            )
        if obj.get_yscale() == "log":
            self.axis_options.append("ymode=log")
            self.axis_options.append(
                "log basis y={{{}}}".format(_try_f2i(obj.yaxis._scale.base))
            )

        # Possible values for get_axisbelow():
        #   True (zorder = 0.5):   Ticks and gridlines are below all Artists.
        #   'line' (zorder = 1.5): Ticks and gridlines are above patches (e.g.
        #                          rectangles) but still below lines / markers.
        #   False (zorder = 2.5):  Ticks and gridlines are above patches and lines /
        #                          markers.
        if not obj.get_axisbelow():
            self.axis_options.append("axis on top")

        # aspect ratio, plot width/height
        aspect = obj.get_aspect()
        if aspect in ["auto", "normal"]:
            aspect_num = None  # just take the given width/height values
        elif aspect == "equal":
            aspect_num = 1.0
        else:
            aspect_num = float(aspect)

        self._set_axis_dimensions(data, aspect_num, xlim, ylim)

        # axis positions
        xaxis_pos = obj.get_xaxis().label_position
        if xaxis_pos == "top":
            # default: "bottom"
            self.axis_options.append("axis x line=top")

        yaxis_pos = obj.get_yaxis().label_position
        if yaxis_pos == "right":
            # default: "left"
            self.axis_options.append("axis y line=right")

        self._ticks(data, obj)

        self._grid(obj, data)

        # axis line styles
        # Assume that the bottom edge color is the color of the entire box.
        axcol = obj.spines["bottom"].get_edgecolor()
        data, col, _ = color.mpl_color2xcolor(data, axcol)
        if col != "black":
            self.axis_options.append("axis line style={{{}}}".format(col))

        # background color
        bgcolor = obj.get_facecolor()

        data, col, _ = color.mpl_color2xcolor(data, bgcolor)
        if col != "white":
            self.axis_options.append("axis background/.style={{fill={}}}".format(col))

        # find color bar
        colorbar = _find_associated_colorbar(obj)
        if colorbar:
            self._colorbar(colorbar, data)

        if self.is_subplot:
            self.content.append("\n\\nextgroupplot")
        else:
            self.content.append("\\begin{axis}")

        return
def __init__ ( self , data , obj ) : self . content = [ ] self . is_colorbar = _is_colorbar_heuristic ( obj ) if self . is_colorbar : return self . nsubplots = 1 self . subplot_index = 0 self . is_subplot = False if isinstance ( obj , mpl . axes . Subplot ) : self . _subplot ( obj , data ) self . axis_options = [ ] if not obj . axison : self . axis_options . append ( "hide x axis" ) self . axis_options . append ( "hide y axis" ) title = obj . get_title ( ) data [ "current axis title" ] = title if title : self . axis_options . append ( u"title={{{}}}" . format ( title ) ) xlabel = obj . get_xlabel ( ) if xlabel : xlabel = mpl_backend_pgf . common_texification ( xlabel ) self . axis_options . append ( u"xlabel={{{}}}" . format ( xlabel ) ) ylabel = obj . get_ylabel ( ) if ylabel : ylabel = mpl_backend_pgf . common_texification ( ylabel ) self . axis_options . append ( u"ylabel={{{}}}" . format ( ylabel ) ) ff = data [ "float format" ] xlim = sorted ( list ( obj . get_xlim ( ) ) ) self . axis_options . append ( ( "xmin=" + ff + ", xmax=" + ff ) . format ( * xlim ) ) ylim = sorted ( list ( obj . get_ylim ( ) ) ) self . axis_options . append ( ( "ymin=" + ff + ", ymax=" + ff ) . format ( * ylim ) ) if obj . get_xscale ( ) == "log" : self . axis_options . append ( "xmode=log" ) self . axis_options . append ( "log basis x={{{}}}" . format ( _try_f2i ( obj . xaxis . _scale . base ) ) ) if obj . get_yscale ( ) == "log" : self . axis_options . append ( "ymode=log" ) self . axis_options . append ( "log basis y={{{}}}" . format ( _try_f2i ( obj . yaxis . _scale . base ) ) ) if not obj . get_axisbelow ( ) : self . axis_options . append ( "axis on top" ) aspect = obj . get_aspect ( ) if aspect in [ "auto" , "normal" ] : aspect_num = None elif aspect == "equal" : aspect_num = 1.0 else : aspect_num = float ( aspect ) self . _set_axis_dimensions ( data , aspect_num , xlim , ylim ) xaxis_pos = obj . get_xaxis ( ) . label_position if xaxis_pos == "top" : self . axis_options . append ( "axis x line=top" ) yaxis_pos = obj . get_yaxis ( ) . label_position if yaxis_pos == "right" : self . axis_options . append ( "axis y line=right" ) self . _ticks ( data , obj ) self . _grid ( obj , data ) axcol = obj . spines [ "bottom" ] . get_edgecolor ( ) data , col , _ = color . mpl_color2xcolor ( data , axcol ) if col != "black" : self . axis_options . append ( "axis line style={{{}}}" . format ( col ) ) bgcolor = obj . get_facecolor ( ) data , col , _ = color . mpl_color2xcolor ( data , bgcolor ) if col != "white" : self . axis_options . append ( "axis background/.style={{fill={}}}" . format ( col ) ) colorbar = _find_associated_colorbar ( obj ) if colorbar : self . _colorbar ( colorbar , data ) if self . is_subplot : self . content . append ( "\n\\nextgroupplot" ) else : self . content . append ( "\\begin{axis}" ) return
Returns the PGFPlots code for an axis environment.