Skip to content

Commit

Permalink
Merge pull request #7284 from QuLogic/backports-2.0
Browse files Browse the repository at this point in the history
Backports for 2.0
  • Loading branch information
tacaswell committed Oct 17, 2016
2 parents a869cc0 + 734b702 commit 92b5c95
Show file tree
Hide file tree
Showing 142 changed files with 4,413 additions and 4,250 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Expand Up @@ -41,6 +41,7 @@ env:
- PANDAS=
- NPROC=2
- TEST_ARGS=--no-pep8
- DELETE_FONT_CACHE=

language: python

Expand All @@ -50,7 +51,7 @@ matrix:
env: MOCK=mock NUMPY=numpy==1.6
- python: 3.4
- python: 3.5
env: PANDAS=pandas
env: PANDAS=pandas DELETE_FONT_CACHE=1
- python: 2.7
env: TEST_ARGS=--pep8
- python: 2.7
Expand Down Expand Up @@ -123,6 +124,9 @@ script:
echo Testing using $NPROC processes
echo The following args are passed to nose $NOSE_ARGS
if [[ $BUILD_DOCS == false ]]; then
if [[ $DELETE_FONT_CACHE == 1 ]]; then
rm -rf ~/.cache/matplotlib
fi
export MPL_REPO_DIR=$PWD # needed for pep8-conformance test of the examples
gdb -return-child-result -batch -ex r -ex bt --args python tests.py -s --processes=$NPROC --process-timeout=300 $TEST_ARGS
else
Expand Down
29 changes: 29 additions & 0 deletions doc/faq/howto_faq.rst
Expand Up @@ -14,6 +14,35 @@ How-To
Plotting: howto
===============

.. _howto-datetime64:

Plot `numpy.datetime64` values
------------------------------

For matplotlib to plot dates (or any scalar with units) a converter
to float needs to be registered with the `matplolib.units` module. The
current best converters for `datetime64` values are in `pandas`. Simply
importing `pandas` ::

import pandas as pd

should be sufficient as `pandas` will try to install the converters
on import. If that does not work, or you need to reset `munits.registry`
you can explicitly install the `pandas` converters by ::

from pandas.tseries import converter as pdtc
pdtc.register()

If you only want to use the `pandas` converter for `datetime64` values ::

from pandas.tseries import converter as pdtc
import matplotlib.units as munits
import numpy as np

munits.registry[np.datetime64] = pdtc.DatetimeConverter()



.. _howto-findobj:

Find all objects in a figure of a certain type
Expand Down
7 changes: 7 additions & 0 deletions doc/mpl_toolkits/axes_grid/api/anchored_artists_api.rst
@@ -0,0 +1,7 @@
:mod:`mpl_toolkits.axes_grid1.anchored_artists`
===============================================

.. automodule:: mpl_toolkits.axes_grid1.anchored_artists
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions doc/mpl_toolkits/axes_grid/api/index.rst
Expand Up @@ -24,4 +24,5 @@

.. toctree::

anchored_artists_api.rst
inset_locator_api.rst
3 changes: 2 additions & 1 deletion doc/users/customizing.rst
Expand Up @@ -8,7 +8,8 @@ Using style sheets
==================

The ``style`` package adds support for easy-to-switch plotting "styles" with
the same parameters as a matplotlibrc_ file.
the same parameters as a matplotlibrc_ file (which is read at startup to
configure matplotlib).

There are a number of pre-defined styles provided by matplotlib. For
example, there's a pre-defined style called "ggplot", which emulates the
Expand Down
28 changes: 14 additions & 14 deletions doc/users/navigation_toolbar.rst
Expand Up @@ -15,16 +15,16 @@ the buttons at the bottom of the toolbar

.. image:: ../../lib/matplotlib/mpl-data/images/forward_large.png

The ``Forward`` and ``Back`` buttons
These are akin to the web browser forward and back buttons. They
are used to navigate back and forth between previously defined
views. They have no meaning unless you have already navigated
somewhere else using the pan and zoom buttons. This is analogous
The ``Home``, ``Forward`` and ``Back`` buttons
These are akin to a web browser's home, forward and back controls.
``Forward`` and ``Back`` are used to navigate back and forth between
previously defined views. They have no meaning unless you have already
navigated somewhere else using the pan and zoom buttons. This is analogous
to trying to click ``Back`` on your web browser before visiting a
new page --nothing happens. ``Home`` always takes you to the
first, default view of your data. For ``Home``, ``Forward`` and
``Back``, think web browser where data views are web pages. Use
the pan and zoom to rectangle to define new views.
new page or ``Forward`` before you have gone back to a page --
nothing happens. ``Home`` always takes you to the
first, default view of your data. Again, all of these buttons should
feel very familiar to any user of a web browser.

.. image:: ../../lib/matplotlib/mpl-data/images/move_large.png

Expand All @@ -37,11 +37,11 @@ The ``Pan/Zoom`` button
where you released. If you press 'x' or 'y' while panning the
motion will be constrained to the x or y axis, respectively. Press
the right mouse button to zoom, dragging it to a new position.
The x axis will be zoomed in proportionate to the rightward
movement and zoomed out proportionate to the leftward movement.
Ditto for the y axis and up/down motions. The point under your
The x axis will be zoomed in proportionately to the rightward
movement and zoomed out proportionately to the leftward movement.
The same is true for the y axis and up/down motions. The point under your
mouse when you begin the zoom remains stationary, allowing you to
zoom to an arbitrary point in the figure. You can use the
zoom in or out around that point as much as you wish. You can use the
modifier keys 'x', 'y' or 'CONTROL' to constrain the zoom to the x
axis, the y axis, or aspect ratio preserve, respectively.

Expand All @@ -54,7 +54,7 @@ The ``Pan/Zoom`` button

The ``Zoom-to-rectangle`` button
Click this toolbar button to activate this mode. Put your mouse
somewhere over and axes and press the left mouse button. Drag the
somewhere over an axes and press the left mouse button. Drag the
mouse while holding the button to a new location and release. The
axes view limits will be zoomed to the rectangle you have defined.
There is also an experimental 'zoom out to rectangle' in this mode
Expand Down
29 changes: 16 additions & 13 deletions doc/users/text_intro.rst
Expand Up @@ -3,22 +3,25 @@
Text introduction
=================

matplotlib has excellent text support, including mathematical
expressions, truetype support for raster and vector outputs, newline
separated text with arbitrary rotations, and unicode support. Because
we embed the fonts directly in the output documents, e.g., for postscript
matplotlib has extensive text support, including support for
mathematical expressions, truetype support for raster and
vector outputs, newline separated text with arbitrary
rotations, and unicode support. Because it embeds
fonts directly in output documents, e.g., for postscript
or PDF, what you see on the screen is what you get in the hardcopy.
`FreeType <http://www.freetype.org/>`_ support
produces very nice, antialiased fonts, that look good even at small
raster sizes. matplotlib includes its own
:mod:`matplotlib.font_manager`, thanks to Paul Barrett, which
implements a cross platform, W3C compliant font finding algorithm.

You have total control over every text property (font size, font
weight, text location and color, etc) with sensible defaults set in
the rc file. And significantly for those interested in mathematical
:mod:`matplotlib.font_manager` (thanks to Paul Barrett), which
implements a cross platform, `W3C <http://www.w3.org/>`
compliant font finding algorithm.

The user has a great deal of control over text properties (font size, font
weight, text location and color, etc.) with sensible defaults set in
the `rc file <http://matplotlib.org/users/customizing.html>`.
And significantly, for those interested in mathematical
or scientific figures, matplotlib implements a large number of TeX
math symbols and commands, to support :ref:`mathematical expressions
math symbols and commands, supporting :ref:`mathematical expressions
<mathtext-tutorial>` anywhere in your figure.


Expand All @@ -31,10 +34,10 @@ interface
* :func:`~matplotlib.pyplot.text` - add text at an arbitrary location to the ``Axes``;
:meth:`matplotlib.axes.Axes.text` in the API.

* :func:`~matplotlib.pyplot.xlabel` - add an axis label to the x-axis;
* :func:`~matplotlib.pyplot.xlabel` - add a label to the x-axis;
:meth:`matplotlib.axes.Axes.set_xlabel` in the API.

* :func:`~matplotlib.pyplot.ylabel` - add an axis label to the y-axis;
* :func:`~matplotlib.pyplot.ylabel` - add a label to the y-axis;
:meth:`matplotlib.axes.Axes.set_ylabel` in the API.

* :func:`~matplotlib.pyplot.title` - add a title to the ``Axes``;
Expand Down
5 changes: 0 additions & 5 deletions doc/users/whats_new/2015-11-05_hidpi.rst

This file was deleted.

2 changes: 1 addition & 1 deletion examples/axes_grid/simple_anchored_artists.py
Expand Up @@ -2,7 +2,7 @@


def draw_text(ax):
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredText
from matplotlib.offsetbox import AnchoredText
at = AnchoredText("Figure 1a",
loc=2, prop=dict(size=8), frameon=True,
)
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/backends/backend_tkagg.py
Expand Up @@ -609,6 +609,9 @@ def destroy(*args):
self.window.update()
else:
self.canvas.draw_idle()
# Raise the new window.
self.canvas.manager.window.attributes('-topmost', 1)
self.canvas.manager.window.attributes('-topmost', 0)
self._shown = True

def destroy(self, *args):
Expand Down
23 changes: 16 additions & 7 deletions lib/matplotlib/mathtext.py
Expand Up @@ -896,7 +896,6 @@ def __init__(self, *args, **kwargs):
self.fontmap = {}
# Include Stix sized alternatives for glyphs
self._fontmap.update({
0 : 'STIXGeneral',
1 : 'STIXSizeOneSym',
2 : 'STIXSizeTwoSym',
3 : 'STIXSizeThreeSym',
Expand Down Expand Up @@ -938,6 +937,7 @@ class DejaVuSerifFonts(DejaVuFonts):
'sf' : 'DejaVu Sans',
'tt' : 'DejaVu Sans Mono',
'ex' : 'DejaVu Serif Display',
0 : 'DejaVu Serif',
}

class DejaVuSansFonts(DejaVuFonts):
Expand All @@ -952,6 +952,7 @@ class DejaVuSansFonts(DejaVuFonts):
'sf' : 'DejaVu Sans',
'tt' : 'DejaVu Sans Mono',
'ex' : 'DejaVu Sans Display',
0 : 'DejaVu Sans',
}

class StixFonts(UnicodeFonts):
Expand Down Expand Up @@ -2003,20 +2004,28 @@ def __init__(self, c, height, depth, state, always=False, factor=None):
alternatives = state.font_output.get_sized_alternatives_for_symbol(
state.font, c)

xHeight = state.font_output.get_xheight(
state.font, state.fontsize, state.dpi)

state = state.copy()
target_total = height + depth
for fontname, sym in alternatives:
state.font = fontname
char = Char(sym, state)
if char.height + char.depth >= target_total:
# Ensure that size 0 is chosen when the text is regular sized but
# with descender glyphs by subtracting 0.2 * xHeight
if char.height + char.depth >= target_total - 0.2 * xHeight:
break

if factor is None:
factor = target_total / (char.height + char.depth)
state.fontsize *= factor
char = Char(sym, state)
shift = 0
if state.font != 0:
if factor is None:
factor = (target_total) / (char.height + char.depth)
state.fontsize *= factor
char = Char(sym, state)

shift = (depth - char.depth)

shift = (depth - char.depth)
Hlist.__init__(self, [char])
self.shift_amount = shift

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/patches.py
Expand Up @@ -1195,7 +1195,7 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False,
"""
if head_width is None:
head_width = 20 * width
head_width = 3 * width
if head_length is None:
head_length = 1.5 * head_width

Expand Down
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 92b5c95

Please sign in to comment.