8000 Merge remote-tracking branch 'upstream/v1.3.x' · matplotlib/matplotlib@9f13f0b · GitHub
[go: up one dir, main page]

Skip to content

Commit 9f13f0b

Browse files
committed
Merge remote-tracking branch 'upstream/v1.3.x'
Conflicts: CHANGELOG
2 parents e37b5c5 + 2b74cb5 commit 9f13f0b

File tree

9 files changed

+53
-31
lines changed

9 files changed

+53
-31
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
2014-04-27 removed un-needed cast to float in stem
1414

15+
2014-04-23 Updated references to "ipython -pylab"
16+
The preferred method for invoking pylab is now using the
17+
"%pylab" magic.
18+
-Chris G.
19+
1520
2014-04-22 Added (re-)generate a simple automatic legend to "Figure Options"
1621
dialog of the Qt4Agg backend.
1722

doc/_templates/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ <h1>Introduction</h1>
6363
For a sampling, see the <a href="{{ pathto('users/screenshots') }}">screenshots</a>, <a href="{{ pathto('gallery') }}">thumbnail</a> gallery, and
6464
<a href="examples/index.html">examples</a> directory</p>
6565

66-
<p>For example, using <tt>"ipython --pylab"</tt> to provide an interactive
67-
environment, to generate 10,000 gaussian random numbers and plot a
68-
histogram with 100 bins, you simply need to
66+
<p>For example, using <tt>"%pylab"</tt> in the IPython shell for
67+
an interactive environment, to generate 10,000 gaussian random numbers
68+
and plot a histogram with 100 bins, you simply need to
6969
type</p>
7070

7171
<pre>

doc/users/image_tutorial.rst

Lines changed: 8 additions & 2 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ At the very least, you'll need to have access to the
1414
:func:`~matplotlib.pyplot.imshow` function. There are a couple of
1515
ways to do it. The easy way for an interactive environment::
1616

17-
$ipython -pylab
17+
$ipython
18+
19+
to enter the ipython shell, followed by::
20+
21+
In [1]: %pylab
22+
23+
to enter the pylab environment.
1824

1925
The imshow function is now directly accessible (it's in your
2026
`namespace <http://bytebaker.com/2008/07/30/python-namespaces/>`_).
@@ -32,7 +38,7 @@ where you use explicit namespaces and control object creation, etc...
3238
In [3]: import numpy as np
3339

3440
Examples below will use the latter method, for clarity. In these
35-
examples, if you use the -pylab method, you can skip the "mpimg." and
41+
examples, if you use the %pylab method, you can skip the "mpimg." and
3642
"plt." prefixes.
3743

3844
.. _importing_data:

doc/users/shell.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ matplotlib aware, so when you start ipython in the *pylab* mode.
2929

3030
.. sourcecode:: ipython
3131

32-
johnh@flag:~> ipython -pylab
32+
johnh@flag:~> ipython
3333
Python 2.4.5 (#4, Apr 12 2008, 09:09:16)
3434
IPython 0.9.0 -- An enhanced Interactive Python.
3535

36+
In [1]: %pylab
37+
3638
Welcome to pylab, a matplotlib-based Python environment.
3739
For more information, type 'help(pylab)'.
3840

39-
In [1]: x = randn(10000)
41+
In [2]: x = randn(10000)
4042

41-
In [2]: hist(x, 100)
43+
In [3]: hist(x, 100)
4244

4345
it sets everything up for you so interactive plotting works as you
4446
would expect it to. Call :func:`~matplotlib.pyplot.figure` and a

lib/matplotlib/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
1313
or using ipython::
1414
15-
ipython -pylab
15+
ipython
16+
17+
at your terminal, followed by::
18+
19+
In [1]: %pylab
20+
21+
at the ipython shell prompt.
1622
1723
For the most part, direct use of the object-oriented library is
1824
encouraged when programming; pyplot is primarily for working

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4485,8 +4485,9 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
44854485
corner of the axes. If None, default to rc `image.origin`.
44864486
44874487
extent : scalars (left, right, bottom, top), optional, default: None
4488-
Data limits for the axes. The default assigns zero-based row,
4489-
column indices to the `x`, `y` centers of the pixels.
4488+
The location, in data-coordinates, of the lower-left and upper-right
4489+
corners of the image. If `None`, the image is positioned such that
4490+
the pixel centers fall on zero-based (row, column) indices.
44904491
44914492
shape : scalars (columns, rows), optional, default: None
44924493
For raw buffer images

lib/matplotlib/backend_bases.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def __call__(self, block=None):
141141
it is a boolean that overrides all other factors
142142
determining whether show blocks by calling mainloop().
143143
The other factors are:
144-
it does not block if run inside "ipython --pylab";
144+
it does not block if run inside ipython's "%pylab" mode
145145
it does not block in interactive mode.
146146
"""
147147
managers = Gcf.get_all_fig_managers()
@@ -165,11 +165,11 @@ def __call__(self, block=None):
165165
ipython_pylab = not pyplot.show._needmain
166166
# IPython versions >= 0.10 tack the _needmain
167167
# attribute onto pyplot.show, and always set
168-
# it to False, when in --pylab mode.
168+
# it to False, when in %pylab mode.
169169
ipython_pylab = ipython_pylab and get_backend() != 'WebAgg'
170170
# TODO: The above is a hack to get the WebAgg backend
171-
# working with `ipython --pylab` until proper integration
172-
# is implemented.
171+
# working with ipython's `%pylab` mode until proper
172+
# integration is implemented.
173173
except AttributeError:
174174
ipython_pylab = False
175175

src/_backend_agg.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,7 @@ RendererAgg::write_rgba(const Py::Tuple& args)
21832183
}
21842184
else
21852185
{
2186+
PyErr_Clear();
21862187
PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(),
21872188
"write");
21882189
if (!(write_method && PyCallable_Check(write_method)))
@@ -2192,7 +2193,11 @@ RendererAgg::write_rgba(const Py::Tuple& args)
21922193
"Object does not appear to be a 8-bit string path or a Python file-like object");
21932194
}
21942195

2196+
#if PY3K
2197+
PyObject_CallFunction(write_method, (char *)"y#", pixBuffer, NUMBYTES);
2198+
#else
21952199
PyObject_CallFunction(write_method, (char *)"s#", pixBuffer, NUMBYTES);
2200+
#endif
21962201

21972202
Py_XDECREF(write_method);
21982203
}

src/file_compat.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ mpl_PyFile_Dup(PyObject *file, char *mode, mpl_off_t *orig_pos)
101101
/* Record the original raw file handle position */
102102
*orig_pos = npy_ftell(handle);
103103
if (*orig_pos == -1) {
104-
PyErr_SetString(PyExc_IOError, "obtaining file position failed");
105-
return NULL;
104+
// handle is a stream, so we don't have to worry about this
105+
return handle;
106106
}
107107

108108
/* Seek raw handle to the Python-side position */
@@ -145,22 +145,19 @@ mpl_PyFile_DupClose(PyObject *file, FILE* handle, mpl_off_t orig_pos)
145145
if (fd == -1) {
146146
return -1;
147147
}
148-
if (npy_lseek(fd, orig_pos, SEEK_SET) == -1) {
149-
PyErr_SetString(PyExc_IOError, "seeking file failed");
150-
return -1;
151-
}
152-
153-
if (position == -1) {
154-
PyErr_SetString(PyExc_IOError, "obtaining file position failed");
155-
return -1;
156-
}
148+
if (npy_lseek(fd, orig_pos, SEEK_SET) != -1) {
149+
if (position == -1) {
150+
PyErr_SetString(PyExc_IOError, "obtaining file position failed");
151+
return -1;
152+
}
157153

158-
/* Seek Python-side handle to the FILE* handle position */
159-
ret = PyObject_CallMethod(file, "seek", MPL_OFF_T_PYFMT "i", position, 0);
160-
if (ret == NULL) {
161-
return -1;
154+
/* Seek Python-side handle to the FILE* handle position */
155+
ret = PyObject_CallMethod(file, "seek", MPL_OFF_T_PYFMT "i", position, 0);
156+
if (ret == NULL) {
157+
return -1;
158+
}
159+
Py_DECREF(ret);
162160
}
163-
Py_DECREF(ret);
164161
return 0;
165162
}
166163

0 commit comments

Comments
 (0)
0