Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff2907b

Browse files
committed
implemented a cross wx version set size func
svn path=/trunk/matplotlib/; revision=5458
1 parent ecba5e3 commit ff2907b

6 files changed

Lines changed: 33 additions & 16 deletions

File tree

doc/devel/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
:Date: |today|
99

1010
.. toctree::
11+
:maxdepth: 2
1112

1213
coding_guide.rst
1314
documenting_mpl.rst

doc/faq/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Frequently asked questions about matplotlib
1111

1212
.. toctree::
13+
:maxdepth: 2
1314

1415
installing_faq.rst
1516
troubleshooting_faq.rst

doc/users/artists.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ container objects store the ``Artists`` that you want to get at.
256256
.. _figure-container:
257257

258258
Figure container
259-
----------------
259+
================
260260

261261
The top level container ``Artist`` is the
262262
:class:`matplotlib.figure.Figure`, and it contains everything in the
@@ -349,7 +349,7 @@ texts A list Figure Text instances
349349
.. _axes-container:
350350

351351
Axes container
352-
--------------
352+
==============
353353

354354
The :class:`matplotlib.axes.Axes` is the center of the matplotlib
355355
universe -- it contains the vast majority of all the ``Artists`` used
@@ -527,7 +527,7 @@ yaxis matplotlib.axis.YAxis instance
527527
.. _axis-container:
528528

529529
Axis containers
530-
---------------
530+
===============
531531

532532
The :class:`matplotlib.axis.Axis` instances handle the drawing of the
533533
tick lines, the grid lines, the tick labels and the axis label. You
@@ -613,7 +613,7 @@ the axes and tick properties
613613
.. _tick-container:
614614

615615
Tick containers
616-
---------------
616+
===============
617617

618618
The :class:`matplotlib.axis.Tick` is the final container object in our
619619
descent from the :class:`~matplotlib.figure.Figure` to the

doc/users/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
:Date: |today|
99

1010
.. toctree::
11+
:maxdepth: 2
1112

1213
intro.rst
1314
pyplot_tutorial.rst

doc/users/pyplot_tutorial.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,24 @@ as your heart desires::
197197

198198
import matplotlib.pyplot as plt
199199
plt.figure(1) # the first figure
200+
plt.subplot(211) # the first subplot in the first figure
200201
plt.plot([1,2,3])
202+
plt.subplot(212) # the second subplot in the first figure
203+
plt.plot([4,5,6])
204+
201205

202206
plt.figure(2) # a second figure
203-
plt.plot([4,5,6])
207+
plt.plot([4,5,6]) # creates a subplot(111) by default
204208

205-
plt.figure(1) # figure 1 current
206-
plt.title('Easy as 1,2,3') # figure 1 title
209+
plt.figure(1) # figure 1 current; subplot(212) still current
210+
plt.subplot(211) # make subplot(211) in figure1 current
211+
plt.title('Easy as 1,2,3') # subplot 211 title
207212

208213
You can clear the current figure with :func:`~matplotlib.pyplot.clf`
209-
and the current axes with :func:`~matplotlib.pyplot.cla`.
214+
and the current axes with :func:`~matplotlib.pyplot.cla`. If you find
215+
this statefulness, annoying, don't despair, this is just a thin
216+
stateful wrapper around an object oriented API, which you can use
217+
instead (see :ref:`artist-tutorial`)
210218

211219
.. _working-with-text:
212220

@@ -216,19 +224,19 @@ Working with text
216224
The :func:`~matplotlib.pyplot.text` command can be used to add text in
217225
an arbitrary location, and the :func:`~matplotlib.pyplot.xlabel`,
218226
:func:`~matplotlib.pyplot.ylabel` and :func:`~matplotlib.pyplot.title`
219-
are used to add text in the indicated locations.
227+
are used tox add text in the indicated locations (see :ref:`text-intro`
228+
for a more detailed example)
220229

221230
.. literalinclude:: figures/pyplot_text.py
222231

223232
.. image:: figures/pyplot_text.png
224233
:scale: 50
225234

226235

227-
All of the text commands The :func:`~matplotlib.pyplot.text` commands
228-
return an :class:`matplotlib.text.Text` instance. Just as with with
229-
lines above, you can customize the properties by passing keyword
230-
arguments into the text functions or using
231-
:func:`~matplotlib.pyplot.setp`::
236+
All of the :func:`~matplotlib.pyplot.text` commands return an
237+
:class:`matplotlib.text.Text` instance. Just as with with lines
238+
above, you can customize the properties by passing keyword arguments
239+
into the text functions or using :func:`~matplotlib.pyplot.setp`::
232240

233241
t = plt.xlabel('my data', fontsize=14, color='red')
234242

lib/matplotlib/backends/backend_wx.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,13 @@ def __init__(self, num, fig):
12341234
statbar = StatusBarWx(self)
12351235
self.SetStatusBar(statbar)
12361236
self.canvas = self.get_canvas(fig)
1237-
self.canvas.SetInitialSize(wx.Size(fig.bbox.width, fig.bbox.height))
1237+
1238+
def do_nothing(*args, **kwargs): pass
1239+
1240+
# try to find the set size func across wx versions
1241+
self.SetSizeFunc = getattr(self.canvas, 'SetInitialSize',
1242+
getattr(self.canvas, 'SetBestFittingSize', do_nothing))
1243+
self.SetSizeFunc(wx.Size(fig.bbox.width, fig.bbox.height))
12381244
self.sizer =wx.BoxSizer(wx.VERTICAL)
12391245
self.sizer.Add(self.canvas, 1, wx.TOP | wx.LEFT | wx.EXPAND)
12401246
# By adding toolbar in sizer, we are able to put it at the bottom
@@ -1355,7 +1361,7 @@ def set_window_title(self, title):
13551361

13561362
def resize(self, width, height):
13571363
'Set the canvas size in pixels'
1358-
self.canvas.SetInitialSize(wx.Size(width, height))
1364+
self.canvas.SetSizeFunc(wx.Size(width, height))
13591365
self.window.GetSizer().Fit(self.window)
13601366

13611367
# Identifiers for toolbar controls - images_wx contains bitmaps for the images

0 commit comments

Comments
 (0)