Ticket #4529: trac_4529-typo_fixes-rebase.2.patch

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

    # HG changeset patch
    # User Punarbasu Purkayastha <ppurka@gmail.com>
    # Date 1338275792 -28800
    # Node ID 3bccd31d9ed3d396d5a1e81e8e918fab83dbe7f9
    # Parent  5792e63c534672c7636b6839d26843ed0ec5cb14
    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 isinstance(scale, (list, tuple)):
     358        scale = scale[0]
     359    if scale == 'semilogy' or scale == 'semilogx':
     360        options['aspect_ratio'] = 'automatic'
     361
    353362    if len(center)==2:
    354363        if r2 is None: r2 = r1
    355364        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 isinstance(scale, (list, tuple)):
     329        scale = scale[0]
     330    if scale == 'semilogy' or scale == 'semilogx':
     331        options['aspect_ratio'] = 'automatic'
     332
    324333    g = Graphics()
    325334    g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
    326335    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 isinstance(scale, (list, tuple)):
     491        scale = scale[0]
     492    if scale == 'semilogy' or scale == 'semilogx':
     493        options['aspect_ratio'] = 'automatic'
     494
    486495    g._set_extra_kwds(Graphics._extract_kwds_for_show(options, ignore=['xmin', 'xmax']))
    487496    g.add_primitive(ContourPlot(xy_data_array, xrange, yrange, options))
    488497    return g
     
    532541      ``basex`` sets the base of the logarithm along the horizontal
    533542      axis and ``basey`` sets the base along the vertical axis.
    534543
    535     - ``scale`` -- (default: `linear`) string. The scale of the axes.
    536       Possible values are `linear`, `loglog`, `semilogx`, `semilogy`.
     544    - ``scale`` -- (default: ``"linear"``) string. The scale of the axes.
     545      Possible values are ``"linear"``, ``"loglog"``, ``"semilogx"``,
     546      ``"semilogy"``.
    537547
    538548      The scale can be also be given as single argument that is a list
    539549      or tuple ``(scale, base)`` or ``(scale, basex, basey)``.
    540550
    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.
     551      The ``"loglog"`` scale sets both the horizontal and vertical axes to
     552      logarithmic scale. The ``"semilogx"`` scale sets the horizontal axis
     553      to logarithmic scale. The ``"semilogy"`` scale sets the vertical axis
     554      to logarithmic scale. The ``"linear"`` scale is the default value
     555      when :class:`~sage.plot.graphics.Graphics` is initialized.
    546556
    547557    EXAMPLES:
    548558
     
    711721      ``basex`` sets the base of the logarithm along the horizontal
    712722      axis and ``basey`` sets the base along the vertical axis.
    713723
    714     - ``scale`` -- (default: `linear`) string. The scale of the axes.
    715       Possible values are `linear`, `loglog`, `semilogx`, `semilogy`.
     724    - ``scale`` -- (default: ``"linear"``) string. The scale of the axes.
     725      Possible values are ``"linear"``, ``"loglog"``, ``"semilogx"``,
     726      ``"semilogy"``.
    716727
    717728      The scale can be also be given as single argument that is a list
    718729      or tuple ``(scale, base)`` or ``(scale, basex, basey)``.
    719730
    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.
     731      The ``"loglog"`` scale sets both the horizontal and vertical axes to
     732      logarithmic scale. The ``"semilogx"`` scale sets the horizontal axis
     733      to logarithmic scale. The ``"semilogy"`` scale sets the vertical axis
     734      to logarithmic scale. The ``"linear"`` scale is the default value
     735      when :class:`~sage.plot.graphics.Graphics` is initialized.
    725736
    726737
    727738    EXAMPLES:
     
    817828    cmap.set_under(incol)
    818829
    819830    g = Graphics()
     831
     832    # Reset aspect_ratio to 'automatic' in case scale is 'semilog[xy]'.
     833    # Otherwise matplotlib complains.
     834    scale = options.get('scale', None)
     835    if isinstance(scale, (list, tuple)):
     836        scale = scale[0]
     837    if scale == 'semilogy' or scale == 'semilogx':
     838        options['aspect_ratio'] = 'automatic'
     839
    820840    g._set_extra_kwds(Graphics._extract_kwds_for_show(options, ignore=['xmin', 'xmax']))
    821841    g.add_primitive(ContourPlot(xy_data_array, xrange,yrange,
    822842                                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 isinstance(scale, (list, tuple)):
     292        scale = scale[0]
     293    if scale == 'semilogy' or scale == 'semilogx':
     294        options['aspect_ratio'] = 'automatic'
     295
    287296    g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
    288297    g.add_primitive(Disk(point, radius, angle, options))
    289298    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 isinstance(scale, (list, tuple)):
     290        scale = scale[0]
     291    if scale == 'semilogy' or scale == 'semilogx':
     292        options['aspect_ratio'] = 'automatic'
     293
    285294    g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
    286295    g.add_primitive(Ellipse(center[0],center[1],r1,r2,angle,options))
    287296    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
     
    16241635    Plotting in logarithmic scale is possible for 2D list plots.
    16251636    There are two different syntaxes available::
    16261637
    1627         sage: yl = [2**k for k in range(10)]
     1638        sage: yl = [2**k for k in range(20)]
    16281639        sage: list_plot(yl, scale='semilogy')       # log axis on vertical
    16291640
    16301641    ::
    16311642
    16321643        sage: list_plot_semilogy(yl)       # same
    16331644
     1645    .. warning::
     1646
     1647        If ``plotjoined`` is `False` then the axis that is in log scale
     1648        must have all points strictly positive. For instance, the following
     1649        plot will show no points in the figure since the points in the
     1650        horizontal axis starts from `(0,1)`.
     1651
    16341652    ::
    16351653
    16361654        sage: list_plot(yl, scale='loglog')         # both axes are log
    16371655
    1638     ::
    1639 
    1640         sage: list_plot_loglog(yl, base=2) # base of log is 2
     1656    Instead this will work. We drop the point `(0,1)`.::
     1657
     1658        sage: list_plot(zip(range(1,len(yl)), yl[1:]), scale='loglog')
     1659
     1660    We use :func:`list_plot_loglog` and plot in a different base.::
     1661
     1662        sage: list_plot_loglog(zip(range(1,len(yl)), yl[1:]), base=2)
    16411663
    16421664    We can also change the scale of the axes in the graphics just before
    16431665    displaying::
     
    17081730
    17091731    For all other inputs, look at the documentation of :func:`plot`.
    17101732
     1733    .. note::
     1734
     1735        - Although it is possible to provide a noninteger ``base``, the
     1736          tick labeling and formatting is not ideal. Hence, in case you do
     1737          use noninteger ``base`` for the logarithm, then provide your own
     1738          tick formatter using the option ``tick_formatter``.
     1739
    17111740    EXAMPLES::
    17121741
    17131742        sage: plot_loglog(exp, (1,10)) # plot in loglog scale with base 10
     
    17381767
    17391768    For all other inputs, look at the documentation of :func:`plot`.
    17401769
     1770    .. note::
     1771
     1772        - Although it is possible to provide a noninteger ``base``, the
     1773          tick labeling and formatting is not ideal. Hence, in case you do
     1774          use noninteger ``base`` for the logarithm, then provide your own
     1775          tick formatter using the option ``tick_formatter``.
     1776
    17411777    EXAMPLES::
    17421778
    17431779        sage: plot_semilogx(exp, (1,10)) # plot in semilogx scale, base 10
     
    17641800
    17651801    For all other inputs, look at the documentation of :func:`plot`.
    17661802
     1803    .. note::
     1804
     1805        - Although it is possible to provide a noninteger ``base``, the
     1806          tick labeling and formatting is not ideal. Hence, in case you do
     1807          use noninteger ``base`` for the logarithm, then provide your own
     1808          tick formatter using the option ``tick_formatter``.
     1809
    17671810    EXAMPLES::
    17681811
    17691812        sage: plot_semilogy(exp, (1,10)) # plot in semilogy scale, base 10
     
    17901833
    17911834    For all other inputs, look at the documentation of :func:`list_plot`.
    17921835
     1836
     1837    .. note::
     1838
     1839        - Although it is possible to provide a noninteger ``base``, the
     1840          tick labeling and formatting is not ideal. Hence, in case you do
     1841          use noninteger ``base`` for the logarithm, then provide your own
     1842          tick formatter using the option ``tick_formatter``.
     1843
    17931844    EXAMPLES::
    17941845
    17951846        sage: yl = [5**k for k in range(10)]; xl = [2**k for k in range(10)]
     
    18031854
    18041855        sage: list_plot_loglog(zip(xl, yl), base=(2,5))
    18051856
     1857    .. warning::
     1858
     1859        If ``plotjoined`` is `False` then the axis that is in log scale
     1860        must have all points strictly positive. For instance, the following
     1861        plot will show no points in the figure since the points in the
     1862        horizontal axis starts from `(0,1)`.
     1863
     1864    ::
     1865
     1866        sage: yl = [2**k for k in range(20)]
     1867        sage: list_plot_loglog(yl)
     1868
     1869    Instead this will work. We drop the point `(0,1)`.::
     1870
     1871        sage: list_plot_loglog(zip(range(1,len(yl)), yl[1:]))
     1872
    18061873    """
    18071874    return list_plot(data, plotjoined=plotjoined, scale='loglog', **kwds)
    18081875
     
    18191886
    18201887    For all other inputs, look at the documentation of :func:`list_plot`.
    18211888
     1889    .. note::
     1890
     1891        - Although it is possible to provide a noninteger ``base``, the
     1892          tick labeling and formatting is not ideal. Hence, in case you do
     1893          use noninteger ``base`` for the logarithm, then provide your own
     1894          tick formatter using the option ``tick_formatter``.
     1895
     1896
    18221897    EXAMPLES::
    18231898
    1824         sage: yl = [5**k for k in range(10)]
    1825         sage: list_plot_semilogx(yl) # plot in semilogx scale, base 10
     1899        sage: yl = [2**k for k in range(12)]
     1900        sage: list_plot_semilogx(zip(yl,yl))
     1901
     1902    .. warning::
     1903
     1904        If ``plotjoined`` is `False` then the horizontal axis must have all
     1905        points strictly positive. Otherwise the plot will come up empty.
     1906        For instance the following plot contains a point at `(0,1)`.
     1907
     1908    ::
     1909
     1910        sage: yl = [2**k for k in range(12)]
     1911        sage: list_plot_semilogx(yl) # plot is empty because of `(0,1)`
     1912
     1913    We remove `(0,1)` to fix this.::
     1914
     1915        sage: list_plot_semilogx(zip(range(1, len(yl)), yl[1:]))
    18261916
    18271917    ::
    18281918
     
    18441934
    18451935    For all other inputs, look at the documentation of :func:`list_plot`.
    18461936
     1937    .. note::
     1938
     1939        - Although it is possible to provide a noninteger ``base``, the
     1940          tick labeling and formatting is not ideal. Hence, in case you do
     1941          use noninteger ``base`` for the logarithm, then provide your own
     1942          tick formatter using the option ``tick_formatter``.
     1943
    18471944    EXAMPLES::
    18481945
    1849         sage: yl = [5**k for k in range(10)]
     1946        sage: yl = [2**k for k in range(12)]
    18501947        sage: list_plot_semilogy(yl) # plot in semilogy scale, base 10
    18511948
     1949    .. warning::
     1950
     1951        If ``plotjoined`` is `False` then the vertical axis must have all
     1952        points strictly positive. Otherwise the plot will come up empty.
     1953        For instance the following plot contains a point at `(1,0)`.
     1954
    18521955    ::
    18531956
    1854         sage: list_plot_semilogy(yl, base=5) # with base 5
     1957        sage: xl = [2**k for k in range(12)]; yl = range(len(xl))
     1958        sage: list_plot_semilogy(zip(xl,yl)) # plot empty due to (1,0)
     1959
     1960    We remove `(1,0)` to fix this.::
     1961
     1962        sage: list_plot_semilogy(zip(xl[1:],yl[1:]))
     1963
     1964
     1965    ::
     1966
     1967        sage: list_plot_semilogy(yl, base=2) # with base 2
    18551968
    18561969    """
    18571970    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 isinstance(scale, (list, tuple)):
     372        scale = scale[0]
     373    if scale == 'semilogy' or scale == 'semilogx':
     374        options['aspect_ratio'] = 'automatic'
     375
    367376    g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
    368377    g.add_primitive(Polygon(xdata, ydata, options))
    369378    if options['legend_label']: