Ticket #4529: trac_4529-typo_fixes-rebase.patch

File trac_4529-typo_fixes-rebase.patch, 18.9 KB (added by kcrisman, 9 years ago)
  • sage/plot/arc.py

    # HG changeset patch
    # User Punarbasu Purkayastha <ppurka@gmail.com>
    # Date 1338275792 -28800
    # Node ID 7eaaee0e5bb03f3672ca1502e9be1dc5ffd35e5e
    # Parent  b866943164a4f7dc55e2578148b39a136f9155a5
    fix typos, add warnings, and fix aspect_ratio
      - fix `linear` to ``"linear"``, etc
      - add warnings to list_plot* and for noninteger base
      - change aspect_ratio to "automatic" for many plots in sage.plot.*
    
    diff --git a/sage/plot/arc.py b/sage/plot/arc.py
    a b  
    350350        NotImplementedError
    351351    """
    352352    from sage.plot.all import Graphics
     353
     354    # Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
     355    # Otherwise matplotlib complains.
     356    scale = options.get('scale', None)
     357    if scale == 'semilogy' or scale == 'semilogx':
     358        options['aspect_ratio'] = 'automatic'
     359
    353360    if len(center)==2:
    354361        if r2 is None: r2 = r1
    355362        g = Graphics()
  • sage/plot/circle.py

    diff --git a/sage/plot/circle.py b/sage/plot/circle.py
    a b  
    321321        1.0
    322322    """
    323323    from sage.plot.all import Graphics
     324
     325    # Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
     326    # Otherwise matplotlib complains.
     327    scale = options.get('scale', None)
     328    if scale == 'semilogy' or scale == 'semilogx':
     329        options['aspect_ratio'] = 'automatic'
     330
    324331    g = Graphics()
    325332    g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
    326333    g.add_primitive(Circle(center[0], center[1], radius, options))
  • sage/plot/contour_plot.py

    diff --git a/sage/plot/contour_plot.py b/sage/plot/contour_plot.py
    a b  
    483483                              for y in xsrange(*ranges[1], include_endpoint=True)]
    484484
    485485    g = Graphics()
     486
     487    # Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
     488    # Otherwise matplotlib complains.
     489    scale = options.get('scale', None)
     490    if scale == 'semilogy' or scale == 'semilogx':
     491        options['aspect_ratio'] = 'automatic'
     492
    486493    g._set_extra_kwds(Graphics._extract_kwds_for_show(options, ignore=['xmin', 'xmax']))
    487494    g.add_primitive(ContourPlot(xy_data_array, xrange, yrange, options))
    488495    return g
     
    532539      ``basex`` sets the base of the logarithm along the horizontal
    533540      axis and ``basey`` sets the base along the vertical axis.
    534541
    535     - ``scale`` -- (default: `linear`) string. The scale of the axes.
    536       Possible values are `linear`, `loglog`, `semilogx`, `semilogy`.
     542    - ``scale`` -- (default: ``"linear"``) string. The scale of the axes.
     543      Possible values are ``"linear"``, ``"loglog"``, ``"semilogx"``,
     544      ``"semilogy"``.
    537545
    538546      The scale can be also be given as single argument that is a list
    539547      or tuple ``(scale, base)`` or ``(scale, basex, basey)``.
    540548
    541       The `loglog` scale sets both the horizontal and vertical axes to
    542       logarithmic scale. The `semilogx` scale sets the horizontal axis
    543       to logarithmic scale. The `semilogy` scale sets the vertical axis
    544       to logarithmic scale. The `linear` scale is the default value
    545       when :class:`Graphics` is initialized.
     549      The ``"loglog"`` scale sets both the horizontal and vertical axes to
     550      logarithmic scale. The ``"semilogx"`` scale sets the horizontal axis
     551      to logarithmic scale. The ``"semilogy"`` scale sets the vertical axis
     552      to logarithmic scale. The ``"linear"`` scale is the default value
     553      when :class:`~sage.plot.graphics.Graphics` is initialized.
    546554
    547555    EXAMPLES:
    548556
     
    711719      ``basex`` sets the base of the logarithm along the horizontal
    712720      axis and ``basey`` sets the base along the vertical axis.
    713721
    714     - ``scale`` -- (default: `linear`) string. The scale of the axes.
    715       Possible values are `linear`, `loglog`, `semilogx`, `semilogy`.
     722    - ``scale`` -- (default: ``"linear"``) string. The scale of the axes.
     723      Possible values are ``"linear"``, ``"loglog"``, ``"semilogx"``,
     724      ``"semilogy"``.
    716725
    717726      The scale can be also be given as single argument that is a list
    718727      or tuple ``(scale, base)`` or ``(scale, basex, basey)``.
    719728
    720       The `loglog` scale sets both the horizontal and vertical axes to
    721       logarithmic scale. The `semilogx` scale sets the horizontal axis
    722       to logarithmic scale. The `semilogy` scale sets the vertical axis
    723       to logarithmic scale. The `linear` scale is the default value
    724       when :class:`Graphics` is initialized.
     729      The ``"loglog"`` scale sets both the horizontal and vertical axes to
     730      logarithmic scale. The ``"semilogx"`` scale sets the horizontal axis
     731      to logarithmic scale. The ``"semilogy"`` scale sets the vertical axis
     732      to logarithmic scale. The ``"linear"`` scale is the default value
     733      when :class:`~sage.plot.graphics.Graphics` is initialized.
    725734
    726735
    727736    EXAMPLES:
     
    817826    cmap.set_under(incol)
    818827
    819828    g = Graphics()
     829
     830    # Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
     831    # Otherwise matplotlib complains.
     832    scale = options.get('scale', None)
     833    if scale == 'semilogy' or scale == 'semilogx':
     834        options['aspect_ratio'] = 'automatic'
     835
    820836    g._set_extra_kwds(Graphics._extract_kwds_for_show(options, ignore=['xmin', 'xmax']))
    821837    g.add_primitive(ContourPlot(xy_data_array, xrange,yrange,
    822838                                dict(contours=[-1e307, 0, 1e307], cmap=cmap, fill=True, **options)))
  • sage/plot/disk.py

    diff --git a/sage/plot/disk.py b/sage/plot/disk.py
    a b  
    284284    """
    285285    from sage.plot.all import Graphics
    286286    g = Graphics()
     287
     288    # Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
     289    # Otherwise matplotlib complains.
     290    scale = options.get('scale', None)
     291    if scale == 'semilogy' or scale == 'semilogx':
     292        options['aspect_ratio'] = 'automatic'
     293
    287294    g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
    288295    g.add_primitive(Disk(point, radius, angle, options))
    289296    if options['legend_label']:
  • sage/plot/ellipse.py

    diff --git a/sage/plot/ellipse.py b/sage/plot/ellipse.py
    a b  
    282282    """
    283283    from sage.plot.all import Graphics
    284284    g = Graphics()
     285
     286    # Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
     287    # Otherwise matplotlib complains.
     288    scale = options.get('scale', None)
     289    if scale == 'semilogy' or scale == 'semilogx':
     290        options['aspect_ratio'] = 'automatic'
     291
    285292    g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
    286293    g.add_primitive(Ellipse(center[0],center[1],r1,r2,angle,options))
    287294    if options['legend_label']:
  • sage/plot/graphics.py

    diff --git a/sage/plot/graphics.py b/sage/plot/graphics.py
    a b  
    11331133        INPUT:
    11341134        - ``figure`` -- the matplotlib figure instance.
    11351135        - ``scale`` -- the scale of the figure. Values it can take are
    1136           `"linear"`, `"loglog"`, `"semilogx"`, `"semilogy"`. See
     1136          ``"linear"``, ``"loglog"``, ``"semilogx"``, ``"semilogy"``. See
    11371137          :meth:`show` for other options it can take.
    11381138        - ``base`` -- the base of the logarithm if a logarithmic scale is
    11391139          set. See :meth:`show` for the options it can take.
     
    13771377            `e`, or `sqrt(2)`, ticks will be formatted nicely at rational
    13781378            multiples of this constant.
    13791379
    1380           .. warning:: This should only be used with the ``ticks`` option
    1381              using nice rational multiples of that constant!
     1380          .. warning::
     1381
     1382             This should only be used with the ``ticks`` option using nice
     1383             rational multiples of that constant!
    13821384
    13831385          - If one of the entries is the string ``"latex"``, then the
    13841386            formatting will be nice typesetting of the ticks.  This is
     
    13951397          ``basex`` sets the base of the logarithm along the horizontal
    13961398          axis and ``basey`` sets the base along the vertical axis.
    13971399
    1398         - ``scale`` -- (default: `"linear"`) string. The scale of the axes.
     1400        - ``scale`` -- (default: ``"linear"``) string. The scale of the axes.
    13991401          Possible values are
    14001402
    1401           - `"linear"` -- linear scaling of both the axes
    1402           - `"loglog"` -- sets both the horizontal and vertical axes to
     1403          - ``"linear"`` -- linear scaling of both the axes
     1404          - ``"loglog"`` -- sets both the horizontal and vertical axes to
    14031405            logarithmic scale
    1404           - `"semilogx"` -- sets only the horizontal axis to logarithmic
     1406          - ``"semilogx"`` -- sets only the horizontal axis to logarithmic
    14051407            scale.
    1406           - `"semilogy"` -- sets only the vertical axis to logarithmic
     1408          - ``"semilogy"`` -- sets only the vertical axis to logarithmic
    14071409            scale.
    14081410
    14091411          The scale can be also be given as single argument that is a list
    14101412          or tuple ``(scale, base)`` or ``(scale, basex, basey)``.
    14111413
    1412           Note: If the ``scale`` is `"linear"`, then irrespective of what
    1413           ``base`` is set to, it will default to 10 and will remain unused.
     1414          .. note::
     1415
     1416            - If the ``scale`` is ``"linear"``, then irrespective of what
     1417              ``base`` is set to, it will default to 10 and will remain
     1418              unused.
     1419
     1420            - Although it is possible to provide a noninteger ``base``, the
     1421              tick labeling and formatting is not ideal. Hence, in case you
     1422              do use noninteger ``base`` for the logarithm, then provide
     1423              your own tick formatter using the option ``tick_formatter``.
    14141424
    14151425        EXAMPLES::
    14161426
     
    22332243
    22342244            # Make the zero tick labels disappear if the axes cross
    22352245            # inside the picture, but only if log scale is not used
    2236             if (xmiddle and ymiddle and xscale == 'linear' and 
     2246            if (xmiddle and ymiddle and xscale == 'linear' and
    22372247                yscale == 'linear'):
    22382248                from sage.plot.plot import SelectiveFormatter
    22392249                subplot.yaxis.set_major_formatter(SelectiveFormatter(
  • sage/plot/plot.py

    diff --git a/sage/plot/plot.py b/sage/plot/plot.py
    a b  
    607607      ``basex`` sets the base of the logarithm along the horizontal
    608608      axis and ``basey`` sets the base along the vertical axis.
    609609
    610     - ``scale`` -- (default: `linear`) string. The scale of the axes.
    611       Possible values are `linear`, `loglog`, `semilogx`, `semilogy`.
     610    - ``scale`` -- (default: ``"linear"``) string. The scale of the axes.
     611      Possible values are ``"linear"``, ``"loglog"``, ``"semilogx"``,
     612      ``"semilogy"``.
    612613
    613614      The scale can be also be given as single argument that is a list
    614615      or tuple ``(scale, base)`` or ``(scale, basex, basey)``.
    615616
    616       The `loglog` scale sets both the horizontal and vertical axes to
    617       logarithmic scale. The `semilogx` scale sets the horizontal axis
    618       to logarithmic scale. The `semilogy` scale sets the vertical axis
    619       to logarithmic scale. The `linear` scale is the default value
     617      The ``"loglog"`` scale sets both the horizontal and vertical axes to
     618      logarithmic scale. The ``"semilogx"`` scale sets the horizontal axis
     619      to logarithmic scale. The ``"semilogy"`` scale sets the vertical axis
     620      to logarithmic scale. The ``"linear"`` scale is the default value
    620621      when :class:`~sage.plot.graphics.Graphics` is initialized.
    621622
    622623    - ``xmin`` - starting x value
     
    632633
    633634    - ``legend_label`` - the label for this item in the legend
    634635
     636    .. note::
     637
     638        - If the ``scale`` is ``"linear"``, then irrespective of what
     639          ``base`` is set to, it will default to 10 and will remain unused.
     640
     641        - Although it is possible to provide a noninteger ``base``, the
     642          tick labeling and formatting is not ideal. Hence, in case you do
     643          use noninteger ``base`` for the logarithm, then provide your own
     644          tick formatter using the option ``tick_formatter``.
     645
    635646    APPEARANCE OPTIONS:
    636647
    637648    The following options affect the appearance of
     
    818829
    819830    ::
    820831
    821         sage: plot_loglog(exp, (1, 10), scale='loglog')   # both axes are log
     832        sage: plot_loglog(exp, (1, 10))   # both axes are log
    822833
    823834    ::
    824835
     
    16221633    Plotting in logarithmic scale is possible for 2D list plots.
    16231634    There are two different syntaxes available::
    16241635
    1625         sage: yl = [2**k for k in range(10)]
     1636        sage: yl = [2**k for k in range(20)]
    16261637        sage: list_plot(yl, scale='semilogy')       # log axis on vertical
    16271638
    16281639    ::
    16291640
    16301641        sage: list_plot_semilogy(yl)       # same
    16311642
     1643    .. warning::
     1644
     1645        If ``plotjoined`` is `False` then the axis that is in log scale
     1646        must have all points strictly positive. For instance, the following
     1647        plot will show no points in the figure since the points in the
     1648        horizontal axis starts from `(0,1)`.
     1649
    16321650    ::
    16331651
    16341652        sage: list_plot(yl, scale='loglog')         # both axes are log
    16351653
    1636     ::
    1637 
    1638         sage: list_plot_loglog(yl, base=2) # base of log is 2
     1654    Instead this will work. We drop the point `(0,1)`.::
     1655
     1656        sage: list_plot(zip(range(1,len(yl)), yl[1:]), scale='loglog')
     1657
     1658    We use :func:`list_plot_loglog` and plot in a different base.::
     1659
     1660        sage: list_plot_loglog(zip(range(1,len(yl)), yl[1:]), base=2)
    16391661
    16401662    We can also change the scale of the axes in the graphics just before
    16411663    displaying::
     
    17061728
    17071729    For all other inputs, look at the documentation of :func:`plot`.
    17081730
     1731    .. note::
     1732
     1733        - Although it is possible to provide a noninteger ``base``, the
     1734          tick labeling and formatting is not ideal. Hence, in case you do
     1735          use noninteger ``base`` for the logarithm, then provide your own
     1736          tick formatter using the option ``tick_formatter``.
     1737
    17091738    EXAMPLES::
    17101739
    17111740        sage: plot_loglog(exp, (1,10)) # plot in loglog scale with base 10
     
    17361765
    17371766    For all other inputs, look at the documentation of :func:`plot`.
    17381767
     1768    .. note::
     1769
     1770        - Although it is possible to provide a noninteger ``base``, the
     1771          tick labeling and formatting is not ideal. Hence, in case you do
     1772          use noninteger ``base`` for the logarithm, then provide your own
     1773          tick formatter using the option ``tick_formatter``.
     1774
    17391775    EXAMPLES::
    17401776
    17411777        sage: plot_semilogx(exp, (1,10)) # plot in semilogx scale, base 10
     
    17621798
    17631799    For all other inputs, look at the documentation of :func:`plot`.
    17641800
     1801    .. note::
     1802
     1803        - Although it is possible to provide a noninteger ``base``, the
     1804          tick labeling and formatting is not ideal. Hence, in case you do
     1805          use noninteger ``base`` for the logarithm, then provide your own
     1806          tick formatter using the option ``tick_formatter``.
     1807
    17651808    EXAMPLES::
    17661809
    17671810        sage: plot_semilogy(exp, (1,10)) # plot in semilogy scale, base 10
     
    17881831
    17891832    For all other inputs, look at the documentation of :func:`list_plot`.
    17901833
     1834
     1835    .. note::
     1836
     1837        - Although it is possible to provide a noninteger ``base``, the
     1838          tick labeling and formatting is not ideal. Hence, in case you do
     1839          use noninteger ``base`` for the logarithm, then provide your own
     1840          tick formatter using the option ``tick_formatter``.
     1841
    17911842    EXAMPLES::
    17921843
    17931844        sage: yl = [5**k for k in range(10)]; xl = [2**k for k in range(10)]
     
    18011852
    18021853        sage: list_plot_loglog(zip(xl, yl), base=(2,5))
    18031854
     1855    .. warning::
     1856
     1857        If ``plotjoined`` is `False` then the axis that is in log scale
     1858        must have all points strictly positive. For instance, the following
     1859        plot will show no points in the figure since the points in the
     1860        horizontal axis starts from `(0,1)`.
     1861
     1862    ::
     1863
     1864        sage: yl = [2**k for k in range(20)]
     1865        sage: list_plot_loglog(yl)
     1866
     1867    Instead this will work. We drop the point `(0,1)`.::
     1868
     1869        sage: list_plot_loglog(zip(range(1,len(yl)), yl[1:]))
     1870
    18041871    """
    18051872    return list_plot(data, plotjoined=plotjoined, scale='loglog', **kwds)
    18061873
     
    18171884
    18181885    For all other inputs, look at the documentation of :func:`list_plot`.
    18191886
     1887    .. note::
     1888
     1889        - Although it is possible to provide a noninteger ``base``, the
     1890          tick labeling and formatting is not ideal. Hence, in case you do
     1891          use noninteger ``base`` for the logarithm, then provide your own
     1892          tick formatter using the option ``tick_formatter``.
     1893
     1894
    18201895    EXAMPLES::
    18211896
    1822         sage: yl = [5**k for k in range(10)]
    1823         sage: list_plot_semilogx(yl) # plot in semilogx scale, base 10
     1897        sage: yl = [2**k for k in range(12)]
     1898        sage: list_plot_semilogx(zip(yl,yl))
     1899
     1900    .. warning::
     1901
     1902        If ``plotjoined`` is `False` then the horizontal axis must have all
     1903        points strictly positive. Otherwise the plot will come up empty.
     1904        For instance the following plot contains a point at `(0,1)`.
     1905
     1906    ::
     1907
     1908        sage: yl = [2**k for k in range(12)]
     1909        sage: list_plot_semilogx(yl) # plot is empty because of `(0,1)`
     1910
     1911    We remove `(0,1)` to fix this.::
     1912
     1913        sage: list_plot_semilogx(zip(range(1, len(yl)), yl[1:]))
    18241914
    18251915    ::
    18261916
     
    18421932
    18431933    For all other inputs, look at the documentation of :func:`list_plot`.
    18441934
     1935    .. note::
     1936
     1937        - Although it is possible to provide a noninteger ``base``, the
     1938          tick labeling and formatting is not ideal. Hence, in case you do
     1939          use noninteger ``base`` for the logarithm, then provide your own
     1940          tick formatter using the option ``tick_formatter``.
     1941
    18451942    EXAMPLES::
    18461943
    1847         sage: yl = [5**k for k in range(10)]
     1944        sage: yl = [2**k for k in range(12)]
    18481945        sage: list_plot_semilogy(yl) # plot in semilogy scale, base 10
    18491946
     1947    .. warning::
     1948
     1949        If ``plotjoined`` is `False` then the vertical axis must have all
     1950        points strictly positive. Otherwise the plot will come up empty.
     1951        For instance the following plot contains a point at `(1,0)`.
     1952
    18501953    ::
    18511954
    1852         sage: list_plot_semilogy(yl, base=5) # with base 5
     1955        sage: xl = [2**k for k in range(12)]; yl = range(len(xl))
     1956        sage: list_plot_semilogy(zip(xl,yl)) # plot empty due to (1,0)
     1957
     1958    We remove `(1,0)` to fix this.::
     1959
     1960        sage: list_plot_semilogy(zip(xl[1:],yl[1:]))
     1961
     1962
     1963    ::
     1964
     1965        sage: list_plot_semilogy(yl, base=2) # with base 2
    18531966
    18541967    """
    18551968    return list_plot(data, plotjoined=plotjoined, scale='semilogy', **kwds)
  • sage/plot/polygon.py

    diff --git a/sage/plot/polygon.py b/sage/plot/polygon.py
    a b  
    364364            options["thickness"] = 1
    365365    xdata, ydata = xydata_from_point_list(points)
    366366    g = Graphics()
     367
     368    # Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
     369    # Otherwise matplotlib complains.
     370    scale = options.get('scale', None)
     371    if scale == 'semilogy' or scale == 'semilogx':
     372        options['aspect_ratio'] = 'automatic'
     373
    367374    g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
    368375    g.add_primitive(Polygon(xdata, ydata, options))
    369376    if options['legend_label']: