From 54380516a983197d9947bd444a08774d6db87c8b Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Mon, 20 May 2013 22:45:03 -0500 Subject: [PATCH 1/6] Clean up text and links in screenshots page of user docs. --- doc/users/screenshots.rst | 172 +++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 85 deletions(-) diff --git a/doc/users/screenshots.rst b/doc/users/screenshots.rst index e56f31d656ee..caef5f9e0c74 100644 --- a/doc/users/screenshots.rst +++ b/doc/users/screenshots.rst @@ -4,13 +4,13 @@ Screenshots ********************** -Here you will find a host of example figures with the code that -generated them +Here you'll find a host of example plots with the code that +generated them. Simple Plot =========== -The most basic :func:`~matplotlib.pyplot.plot`, with text labels +Here's a very basic :func:`~matplotlib.pyplot.plot` with text labels: .. plot:: mpl_examples/pylab_examples/simple_plot.py @@ -19,8 +19,8 @@ The most basic :func:`~matplotlib.pyplot.plot`, with text labels Subplot demo ============ -Multiple regular axes (numrows by numcolumns) are created with the -:func:`~matplotlib.pyplot.subplot` command. +Multiple axes (i.e. subplots) are created with the +:func:`~matplotlib.pyplot.subplot` command: .. plot:: mpl_examples/subplots_axes_and_figures/subplot_demo.py @@ -30,7 +30,7 @@ Histograms ========== The :func:`~matplotlib.pyplot.hist` command automatically generates -histograms and will return the bin counts or probabilities +histograms and returns the bin counts or probabilities: .. plot:: mpl_examples/statistics/histogram_demo_features.py @@ -40,8 +40,8 @@ histograms and will return the bin counts or probabilities Path demo ========= -You can add arbitrary paths in matplotlib as of release 0.98. See -the :mod:`matplotlib.path`. +You can add arbitrary paths in matplotlib using the +:mod:`matplotlib.path` module: .. plot:: mpl_examples/shapes_and_collections/path_patch_demo.py @@ -52,13 +52,14 @@ mplot3d The mplot3d toolkit (see :ref:`toolkit_mplot3d-tutorial` and :ref:`mplot3d-examples-index`) has support for simple 3d graphs -including surface, wireframe, scatter, and bar charts (added in -matlpotlib-0.99). Thanks to John Porter, Jonathon Taylor and Reinier -Heeres for the mplot3d toolkit. The toolkit is included with all -standard matplotlib installs. +including surface, wireframe, scatter, and bar charts. .. plot:: mpl_examples/mplot3d/surface3d_demo.py +Thanks to John Porter, Jonathon Taylor, Reinier Heeres, and Ben Root for +the `mplot3d` toolkit. This toolkit is included with all standard matplotlib +installs. + .. _screenshots_ellipse_demo: @@ -67,12 +68,10 @@ Ellipses In support of the `Phoenix `_ mission to -Mars, which used matplotlib in ground tracking of the spacecraft, -Michael Droettboom built on work by Charlie Moad to provide an -extremely accurate 8-spline approximation to elliptical arcs (see -:class:`~matplotlib.patches.Arc`) in the viewport. This -provides a scale free, accurate graph of the arc regardless of zoom -level +Mars (which used matplotlib to display ground tracking of spacecraft), +Michael Droettboom built on work by Charlie Moad to provide an extremely +accurate 8-spline approximation to elliptical arcs (see +:class:`~matplotlib.patches.Arc`), which are insensitive to zoom level. .. plot:: mpl_examples/pylab_examples/ellipse_demo.py @@ -81,27 +80,29 @@ level Bar charts ========== -The :func:`~matplotlib.pyplot.bar` -command takes error bars as an optional argument. You can also use up -and down bars, stacked bars, candlestick bars, etc, ... See -`bar_stacked.py `_ for another example. -You can make horizontal bar charts with the -:func:`~matplotlib.pyplot.barh` command. +Bar charts are simple to create using the :func:`~matplotlib.pyplot.bar` +command, which includes customizations such as error bars: .. plot:: mpl_examples/pylab_examples/barchart_demo.py +It's also simple to create stacked bars +(`bar_stacked.py `_), +candlestick bars +(`bar_stacked.py `_), +and horizontal bar charts +(`barh_demo.py `_). + .. _screenshots_pie_demo: Pie charts ========== -The :func:`~matplotlib.pyplot.pie` command -uses a MATLAB compatible syntax to produce pie charts. Optional -features include auto-labeling the percentage of area, exploding one -or more wedges out from the center of the pie, and a shadow effect. -Take a close look at the attached code that produced this figure; nine -lines of code. +The :func:`~matplotlib.pyplot.pie` command allows you to easily create pie +charts. Optional features include auto-labeling the percentage of area, +exploding one or more wedges from the center of the pie, and a shadow effect. +Take a close look at the attached code, which generates this figure in just +a few lines of code. .. plot:: mpl_examples/pie_and_polar_charts/pie_demo_features.py @@ -110,23 +111,23 @@ lines of code. Table demo ========== -The :func:`~matplotlib.pyplot.table` command will place a text table -on the axes +The :func:`~matplotlib.pyplot.table` command adds a text table +to an axes. .. plot:: mpl_examples/pylab_examples/table_demo.py .. _screenshots_scatter_demo: + Scatter demo ============ The :func:`~matplotlib.pyplot.scatter` command makes a scatter plot -with (optional) size and color arguments. This example plots changes -in Google stock price from one day to the next with the sizes coding -trading volume and the colors coding price change in day i. Here the -alpha attribute is used to make semitransparent circle markers with -the Agg backend (see :ref:`what-is-a-backend`) +with (optional) size and color arguments. This example plots changes +in Google's stock price, with marker sizes reflecting the +trading volume and colors varying with time. Here, the +alpha attribute is used to make semitransparent circle markers. .. plot:: mpl_examples/pylab_examples/scatter_demo2.py @@ -138,8 +139,8 @@ Slider demo Matplotlib has basic GUI widgets that are independent of the graphical user interface you are using, allowing you to write cross GUI figures -and widgets. See matplotlib.widgets and the widget `examples -` +and widgets. See :mod:`matplotlib.widgets` and the +`widget examples <../examples/widgets/index.html>`_. .. plot:: mpl_examples/widgets/slider_demo.py @@ -150,34 +151,33 @@ Fill demo ========= The :func:`~matplotlib.pyplot.fill` command lets you -plot filled polygons. Thanks to Andrew Straw for providing this -function +plot filled curves and polygons: .. plot:: mpl_examples/lines_bars_and_markers/fill_demo.py +Thanks to Andrew Straw for adding this function. .. _screenshots_date_demo: Date demo ========= -You can plot date data with major and minor ticks and custom tick -formatters for both the major and minor ticks; see matplotlib.ticker -and matplotlib.dates for details and usage. +You can plot date data with major and minor ticks and custom tick formatters +for both. .. plot:: mpl_examples/api/date_demo.py +See :mod:`matplotlib.ticker` and :mod:`matplotlib.dates` for details and usage. + .. _screenshots_jdh_demo: Financial charts ================ -You can make much more sophisticated financial plots. This example -emulates one of the `ChartDirector -`_ financial plots. -Some of the data in the plot, are real financial data, some are random -traces that I used since the goal was to illustrate plotting -techniques, not market analysis! +You can make sophisticated financial plots by combining the various +plot functions, layout commands, and labeling tools provided by matplotlib. +The following example emulates one of the financial plots in +`ChartDirector `_: .. plot:: mpl_examples/pylab_examples/finance_work2.py @@ -188,9 +188,7 @@ techniques, not market analysis! Basemap demo ============ -Jeff Whitaker's :ref:`toolkit_basemap` add-on toolkit makes it possible to plot data on many -different map projections. This example shows how to plot contours, markers and text -on an orthographic projection, with NASA's "blue marble" satellite image as a background. +Jeff Whitaker's :ref:`toolkit_basemap` add-on toolkit makes it possible to plot data on many different map projections. This example shows how to plot contours, markers and text on an orthographic projection, with NASA's "blue marble" satellite image as a background. .. plot:: pyplots/plotmap.py @@ -201,16 +199,14 @@ Log plots The :func:`~matplotlib.pyplot.semilogx`, :func:`~matplotlib.pyplot.semilogy` and -:func:`~matplotlib.pyplot.loglog` functions generate log scaling on the -respective axes. The lower subplot uses a base10 log on the xaxis and -a base 4 log on the yaxis. Thanks to Andrew Straw, Darren Dale and -Gregory Lielens for contributions to the log scaling -infrastructure. - - +:func:`~matplotlib.pyplot.loglog` functions simplify the creation of +logarithmic plots. .. plot:: mpl_examples/pylab_examples/log_demo.py +Thanks to Andrew Straw, Darren Dale and Gregory Lielens for contributions +log-scaling infrastructure. + .. _screenshots_polar_demo: Polar plots @@ -222,40 +218,43 @@ The :func:`~matplotlib.pyplot.polar` command generates polar plots. .. _screenshots_legend_demo: + Legends ======= The :func:`~matplotlib.pyplot.legend` command automatically -generates figure legends, with MATLAB compatible legend placement -commands. Thanks to Charles Twardy for input on the legend -command +generates figure legends, with MATLAB-compatible legend placement +commands. .. plot:: mpl_examples/pylab_examples/legend_demo.py +Thanks to Charles Twardy for input on the legend command. + .. _screenshots_mathtext_examples_demo: Mathtext_examples ================= -A sampling of the many TeX expressions now supported by matplotlib's -internal mathtext engine. The mathtext module provides TeX style -mathematical expressions using `freetype2 -`_ and the BaKoMa -computer modern or `STIX `_ fonts. See the -:mod:`matplotlib.mathtext` module for additional. matplotlib mathtext -is an independent implementation, and does not required TeX or any -external packages installed on your computer. See the tutorial at -:ref:`mathtext-tutorial`. +Below is a sampling of the many TeX expressions now supported by matplotlib's +internal mathtext engine. The mathtext module provides TeX style mathematical +expressions using `freetype2 `_ +and the BaKoMa computer modern or `STIX `_ fonts. +See the :mod:`matplotlib.mathtext` module for additional details. .. plot:: mpl_examples/pylab_examples/mathtext_examples.py +Matplotlib's mathtext infrastructure is an independent implementation and +does not require TeX or any external packages installed on your computer. See +the tutorial at :ref:`mathtext-tutorial`. + + .. _screenshots_tex_demo: Native TeX rendering ==================== Although matplotlib's internal math rendering engine is quite -powerful, sometimes you need TeX, and matplotlib supports external TeX +powerful, sometimes you need TeX. Matplotlib supports external TeX rendering of strings with the *usetex* option. .. plot:: pyplots/tex_demo.py @@ -265,17 +264,20 @@ rendering of strings with the *usetex* option. EEG demo ========= -You can embed matplotlib into pygtk, wxpython, Tk, FLTK or Qt -applications. Here is a screenshot of an eeg viewer called pbrain -which is part of the NeuroImaging in Python suite `NIPY -`_. Pbrain is written in pygtk using -matplotlib. The lower axes uses :func:`~matplotlib.pyplot.specgram` -to plot the spectrogram of one of the EEG channels. For an example of -how to use the navigation toolbar in your applications, see -:ref:`user_interfaces-embedding_in_gtk2`. If you want to use -matplotlib in a wx application, see -:ref:`user_interfaces-embedding_in_wx2`. If you want to work with -`glade `_, see -:ref:`user_interfaces-mpl_with_glade`. +You can embed matplotlib into pygtk, wx, Tk, FLTK, or Qt +applications. Here is a screenshot of an EEG viewer called pbrain, +which is part of the NeuroImaging in Python suite +`NIPY `_. .. image:: ../_static/eeg_small.png + +The lower axes uses :func:`~matplotlib.pyplot.specgram` +to plot the spectrogram of one of the EEG channels. + +For examples of how to embed matplotlib in different toolkits, see: + + * :ref:`user_interfaces-embedding_in_gtk2` + * :ref:`user_interfaces-embedding_in_wx2` + * :ref:`user_interfaces-mpl_with_glade` + * :ref:`user_interfaces-embedding_in_qt` + * :ref:`user_interfaces-embedding_in_tk` From 84188bf7791af8bbbdab861269ec6b713cb233c4 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Tue, 21 May 2013 00:47:22 -0500 Subject: [PATCH 2/6] Tweak aesthetics of plots in screenshots page. These changes also cleanup the code a bit, as described by MEP 12. --- doc/pyplots/tex_demo.py | 38 +++---- examples/api/legend_demo.py | 65 ++++++------ examples/pylab_examples/barchart_demo.py | 61 ++++++------ examples/pylab_examples/legend_demo.py | 68 ++++++------- examples/pylab_examples/polar_demo.py | 69 +++---------- examples/pylab_examples/scatter_demo2.py | 29 +++--- examples/pylab_examples/table_demo.py | 121 ++++++++--------------- 7 files changed, 179 insertions(+), 272 deletions(-) diff --git a/doc/pyplots/tex_demo.py b/doc/pyplots/tex_demo.py index 3bdbb77a8168..a5288d749d86 100644 --- a/doc/pyplots/tex_demo.py +++ b/doc/pyplots/tex_demo.py @@ -1,5 +1,6 @@ -#!/usr/bin/env python """ +Demo of TeX rendering. + You can use TeX to render all of your matplotlib text if the rc parameter text.usetex is set. This works currently on the agg and ps backends, and requires that you have tex and the other dependencies @@ -10,26 +11,25 @@ ~/.tex.cache """ -from matplotlib import rc -from numpy import arange, cos, pi -from matplotlib.pyplot import figure, axes, plot, xlabel, ylabel, title, \ - grid, savefig, show +import numpy as np +import matplotlib.pyplot as plt -rc('text', usetex=True) -rc('font', family='serif') -figure(1, figsize=(6,4)) -ax = axes([0.1, 0.1, 0.8, 0.7]) -t = arange(0.0, 1.0+0.01, 0.01) -s = cos(2*2*pi*t)+2 -plot(t, s) +# Example data +t = np.arange(0.0, 1.0 + 0.01, 0.01) +s = np.cos(4 * np.pi * t) + 2 -xlabel(r'\textbf{time (s)}') -ylabel(r'\textit{voltage (mV)}',fontsize=16) -title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!", - fontsize=16, color='r') -grid(True) -savefig('tex_demo') +plt.rc('text', usetex=True) +plt.rc('font', family='serif') +plt.plot(t, s) +plt.xlabel(r'\textbf{time} (s)') +plt.ylabel(r'\textit{voltage} (mV)',fontsize=16) +plt.title(r"\TeX\ is Number " + r"$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!", + fontsize=16, color='gray') +# Make room for the ridiculously large title. +plt.subplots_adjust(top=0.8) -show() +plt.savefig('tex_demo') +plt.show() diff --git a/examples/api/legend_demo.py b/examples/api/legend_demo.py index 31d257f1e831..63f25a46bb26 100644 --- a/examples/api/legend_demo.py +++ b/examples/api/legend_demo.py @@ -1,41 +1,42 @@ +""" +Demo of the legend function with a few features. + +In addition to the basic legend, this demo shows a few optional features: + + * Custom legend placement. + * A keyword argument to a drop-shadow. + * Setting the background color. + * Setting the font size. + * Setting the line width. +""" import numpy as np import matplotlib.pyplot as plt -a = np.arange(0,3,.02) -b = np.arange(0,3,.02) + +# Example data +a = np.arange(0,3, .02) +b = np.arange(0,3, .02) c = np.exp(a) d = c[::-1] -fig = plt.figure() -ax = fig.add_subplot(111) -ax.plot(a,c,'k--',a,d,'k:',a,c+d,'k') -leg = ax.legend(('Model length', 'Data length', 'Total message length'), - 'upper center', shadow=True) -ax.set_ylim([-1,20]) -ax.grid(False) -ax.set_xlabel('Model complexity --->') -ax.set_ylabel('Message length --->') -ax.set_title('Minimum Message Length') - -ax.set_yticklabels([]) -ax.set_xticklabels([]) - -# set some legend properties. All the code below is optional. The -# defaults are usually sensible but if you need more control, this -# shows you how - -# the matplotlib.patches.Rectangle instance surrounding the legend -frame = leg.get_frame() -frame.set_facecolor('0.80') # set the frame face color to light gray - -# matplotlib.text.Text instances -for t in leg.get_texts(): - t.set_fontsize('small') # the legend text fontsize - -# matplotlib.lines.Line2D instances -for l in leg.get_lines(): - l.set_linewidth(1.5) # the legend line width -plt.show() +# Create plots with pre-defined labels. +# Alternatively, you can pass labels explicitly when calling `legend`. +fig, ax = plt.subplots() +ax.plot(a, c, 'k--', label='Model length') +ax.plot(a, d, 'k:', label='Data length') +ax.plot(a, c+d, 'k', label='Total message length') + +# Now add the legend with some customizations. +legend = ax.legend(loc='upper center', shadow=True) +# The frame is matplotlib.patches.Rectangle instance surrounding the legend. +frame = legend.get_frame() +frame.set_facecolor('0.90') +# Set the fontsize +for label in legend.get_texts(): + label.set_fontsize('large') +for label in legend.get_lines(): + label.set_linewidth(1.5) # the legend line width +plt.show() diff --git a/examples/pylab_examples/barchart_demo.py b/examples/pylab_examples/barchart_demo.py index e5f86cf4d2c5..e71357d743e3 100644 --- a/examples/pylab_examples/barchart_demo.py +++ b/examples/pylab_examples/barchart_demo.py @@ -1,44 +1,43 @@ - -#!/usr/bin/env python +""" +Bar chart demo with pairs of bars grouped for easy comparison. +""" import numpy as np import matplotlib.pyplot as plt -N = 5 -menMeans = (20, 35, 30, 35, 27) -menStd = (2, 3, 4, 1, 2) -ind = np.arange(N) # the x locations for the groups -width = 0.35 # the width of the bars +n_groups = 5 +means_men = (20, 35, 30, 35, 27) +std_men = (2, 3, 4, 1, 2) -plt.subplot(111) -rects1 = plt.bar(ind, menMeans, width, - color='r', - yerr=menStd, - error_kw=dict(elinewidth=6, ecolor='pink')) +means_women = (25, 32, 34, 20, 25) +std_women = (3, 5, 2, 3, 3) -womenMeans = (25, 32, 34, 20, 25) -womenStd = (3, 5, 2, 3, 3) -rects2 = plt.bar(ind+width, womenMeans, width, - color='y', - yerr=womenStd, - error_kw=dict(elinewidth=6, ecolor='yellow')) +index = np.arange(n_groups) +bar_width = 0.35 -# add some -plt.ylabel('Scores') -plt.title('Scores by group and gender') -plt.xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') ) +opacity = 0.4 +error_config = {'ecolor': '0.3'} -plt.legend( (rects1[0], rects2[0]), ('Men', 'Women') ) +rects1 = plt.bar(index, means_men, bar_width, + alpha=opacity, + color='b', + yerr=std_men, + error_kw=error_config, + label='Men') -def autolabel(rects): - # attach some text labels - for rect in rects: - height = rect.get_height() - plt.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height), - ha='center', va='bottom') +rects2 = plt.bar(index + bar_width, means_women, bar_width, + alpha=opacity, + color='r', + yerr=std_women, + error_kw=error_config, + label='Women') -autolabel(rects1) -autolabel(rects2) +plt.xlabel('Group') +plt.ylabel('Scores') +plt.title('Scores by group and gender') +plt.xticks(index + bar_width, ('A', 'B', 'C', 'D', 'E')) +plt.legend() +plt.tight_layout() plt.show() diff --git a/examples/pylab_examples/legend_demo.py b/examples/pylab_examples/legend_demo.py index 34a4a56981f2..63f25a46bb26 100644 --- a/examples/pylab_examples/legend_demo.py +++ b/examples/pylab_examples/legend_demo.py @@ -1,46 +1,42 @@ -#!/usr/bin/env python -# Thanks to Charles Twardy for this example -# -#See http://matplotlib.org/examples/pylab_examples/legend_demo2.html -# for an example controlling which lines the legend uses and the order -# they are drawn in. +""" +Demo of the legend function with a few features. +In addition to the basic legend, this demo shows a few optional features: + + * Custom legend placement. + * A keyword argument to a drop-shadow. + * Setting the background color. + * Setting the font size. + * Setting the line width. +""" import numpy as np import matplotlib.pyplot as plt -a = np.arange(0,3,.02) -b = np.arange(0,3,.02) + +# Example data +a = np.arange(0,3, .02) +b = np.arange(0,3, .02) c = np.exp(a) d = c[::-1] -ax = plt.subplot(111) -plt.plot(a,c,'k--',a,d,'k:',a,c+d,'k') -plt.legend(('Model length', 'Data length', 'Total message length'), - 'upper center', shadow=True, fancybox=True) -plt.ylim([-1,20]) -plt.grid(False) -plt.xlabel('Model complexity --->') -plt.ylabel('Message length --->') -plt.title('Minimum Message Length') - -plt.setp(plt.gca(), 'yticklabels', []) -plt.setp(plt.gca(), 'xticklabels', []) - -# set some legend properties. All the code below is optional. The -# defaults are usually sensible but if you need more control, this -# shows you how -leg = plt.gca().get_legend() -ltext = leg.get_texts() # all the text.Text instance in the legend -llines = leg.get_lines() # all the lines.Line2D instance in the legend -frame = leg.get_frame() # the patch.Rectangle instance surrounding the legend - -# see text.Text, lines.Line2D, and patches.Rectangle for more info on -# the settable properties of lines, text, and rectangles -frame.set_facecolor('0.80') # set the frame face color to light gray -plt.setp(ltext, fontsize='small') # the legend text fontsize -plt.setp(llines, linewidth=1.5) # the legend linewidth -#leg.draw_frame(False) # don't draw the legend frame -plt.show() +# Create plots with pre-defined labels. +# Alternatively, you can pass labels explicitly when calling `legend`. +fig, ax = plt.subplots() +ax.plot(a, c, 'k--', label='Model length') +ax.plot(a, d, 'k:', label='Data length') +ax.plot(a, c+d, 'k', label='Total message length') +# Now add the legend with some customizations. +legend = ax.legend(loc='upper center', shadow=True) +# The frame is matplotlib.patches.Rectangle instance surrounding the legend. +frame = legend.get_frame() +frame.set_facecolor('0.90') +# Set the fontsize +for label in legend.get_texts(): + label.set_fontsize('large') + +for label in legend.get_lines(): + label.set_linewidth(1.5) # the legend line width +plt.show() diff --git a/examples/pylab_examples/polar_demo.py b/examples/pylab_examples/polar_demo.py index 9492b59e3d93..3127cb55fde2 100644 --- a/examples/pylab_examples/polar_demo.py +++ b/examples/pylab_examples/polar_demo.py @@ -1,64 +1,17 @@ -#!/usr/bin/env python -# -# matplotlib now has a PolarAxes class and a polar function in the -# matplotlib interface. This is considered alpha and the interface -# may change as we work out how polar axes should best be integrated -# -# The only function that has been tested on polar axes is "plot" (the -# pylab interface function "polar" calls ax.plot where ax is a -# PolarAxes) -- other axes plotting functions may work on PolarAxes -# but haven't been tested and may need tweaking. -# -# you can get a PolarSubplot instance by doing, for example -# -# subplot(211, polar=True) -# -# or a PolarAxes instance by doing -# axes([left, bottom, width, height], polar=True) -# -# The view limits (eg xlim and ylim) apply to the lower left and upper -# right of the rectangular box that surrounds to polar axes. e.g., if -# you have -# -# r = arange(0,1,0.01) -# theta = 2*pi*r -# -# the lower left corner is 5/4pi, sqrt(2) and the -# upper right corner is 1/4pi, sqrt(2) -# -# you could change the radial bounding box (zoom out) by setting the -# ylim (radial coordinate is the second argument to the plot command, -# as in MATLAB, though this is not advised currently because it is not -# clear to me how the axes should behave in the change of view limits. -# Please advise me if you have opinions. Likewise, the pan/zoom -# controls probably do not do what you think they do and are better -# left alone on polar axes. Perhaps I will disable them for polar -# axes unless we come up with a meaningful, useful and functional -# implementation for them. -# -# See the pylab rgrids and thetagrids functions for -# information on how to customize the grid locations and labels -import matplotlib +""" +Demo of a line plot on a polar axis. +""" import numpy as np -from matplotlib.pyplot import figure, show, rc, grid +import matplotlib.pyplot as plt -# radar green, solid grid lines -rc('grid', color='#316931', linewidth=1, linestyle='-') -rc('xtick', labelsize=15) -rc('ytick', labelsize=15) - -# force square figure and square axes looks better for polar, IMO -width, height = matplotlib.rcParams['figure.figsize'] -size = min(width, height) -# make a square figure -fig = figure(figsize=(size, size)) -ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c') r = np.arange(0, 3.0, 0.01) -theta = 2*np.pi*r -ax.plot(theta, r, color='#ee8d18', lw=3) +theta = 2 * np.pi * r + +ax = plt.subplot(111, polar=True) +ax.plot(theta, r, color='r', linewidth=3) ax.set_rmax(2.0) -grid(True) +ax.grid(True) -ax.set_title("And there was much rejoicing!", fontsize=20) -show() +ax.set_title("A line plot on a polar axis", va='bottom') +plt.show() diff --git a/examples/pylab_examples/scatter_demo2.py b/examples/pylab_examples/scatter_demo2.py index 6c06adf27980..6eb9e18a192f 100644 --- a/examples/pylab_examples/scatter_demo2.py +++ b/examples/pylab_examples/scatter_demo2.py @@ -1,38 +1,33 @@ """ -make a scatter plot with varying color and size arguments +Demo of scatter plot with varying marker colors and sizes. """ -import matplotlib import numpy as np import matplotlib.pyplot as plt -import matplotlib.mlab as mlab import matplotlib.cbook as cbook -# load a numpy record array from yahoo csv data with fields date, +# Load a numpy record array from yahoo csv data with fields date, # open, close, volume, adj_close from the mpl-data/example directory. # The record array stores python datetime.date as an object array in # the date column datafile = cbook.get_sample_data('goog.npy') -r = np.load(datafile).view(np.recarray) -r = r[-250:] # get the most recent 250 trading days +price_data = np.load(datafile).view(np.recarray) +price_data = price_data[-250:] # get the most recent 250 trading days -delta1 = np.diff(r.adj_close)/r.adj_close[:-1] +delta1 = np.diff(price_data.adj_close)/price_data.adj_close[:-1] -# size in points ^2 -volume = (15*r.volume[:-2]/r.volume[0])**2 -close = 0.003*r.close[:-2]/0.003*r.open[:-2] +# Marker size in units of points^2 +volume = (15 * price_data.volume[:-2] / price_data.volume[0])**2 +close = 0.003 * price_data.close[:-2] / 0.003 * price_data.open[:-2] -fig = plt.figure() -ax = fig.add_subplot(111) -ax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.75) - -#ticks = arange(-0.06, 0.061, 0.02) -#xticks(ticks) -#yticks(ticks) +fig, ax = plt.subplots() +ax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.5) ax.set_xlabel(r'$\Delta_i$', fontsize=20) ax.set_ylabel(r'$\Delta_{i+1}$', fontsize=20) ax.set_title('Volume and percent change') + ax.grid(True) +fig.tight_layout() plt.show() diff --git a/examples/pylab_examples/table_demo.py b/examples/pylab_examples/table_demo.py index a4495fb97174..8e80056c347d 100644 --- a/examples/pylab_examples/table_demo.py +++ b/examples/pylab_examples/table_demo.py @@ -1,57 +1,9 @@ -#!/usr/bin/env python -import matplotlib +""" +Demo of table function to display a table within a plot. +""" +import numpy as np +import matplotlib.pyplot as plt -from pylab import * -from matplotlib.colors import colorConverter - - -#Some simple functions to generate colours. -def pastel(colour, weight=2.4): - """ Convert colour into a nice pastel shade""" - rgb = asarray(colorConverter.to_rgb(colour)) - # scale colour - maxc = max(rgb) - if maxc < 1.0 and maxc > 0: - # scale colour - scale = 1.0 / maxc - rgb = rgb * scale - # now decrease saturation - total = sum(rgb) - slack = 0 - for x in rgb: - slack += 1.0 - x - - # want to increase weight from total to weight - # pick x s.t. slack * x == weight - total - # x = (weight - total) / slack - x = (weight - total) / slack - - rgb = [c + (x * (1.0-c)) for c in rgb] - - return rgb - -def get_colours(n): - """ Return n pastel colours. """ - base = asarray([[1,0,0], [0,1,0], [0,0,1]]) - - if n <= 3: - return base[0:n] - - # how many new colours to we need to insert between - # red and green and between green and blue? - needed = (((n - 3) + 1) / 2, (n - 3) / 2) - - colours = [] - for start in (0, 1): - for x in linspace(0, 1, needed[start]+2): - colours.append((base[start] * (1.0 - x)) + - (base[start+1] * x)) - - return [pastel(c) for c in colours[0:n]] - - - -axes([0.2, 0.2, 0.7, 0.6]) # leave room below the axes for the table data = [[ 66386, 174296, 75131, 577908, 32015], [ 58230, 381139, 78045, 99308, 160454], @@ -59,34 +11,45 @@ def get_colours(n): [ 78415, 81858, 150656, 193263, 69638], [ 139361, 331509, 343164, 781380, 52269]] -colLabels = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail') -rowLabels = ['%d year' % x for x in (100, 50, 20, 10, 5)] +columns = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail') +rows = ['%d year' % x for x in (100, 50, 20, 10, 5)] + +values = np.arange(0, 2500, 500) +value_increment = 1000 -# Get some pastel shades for the colours -colours = get_colours(len(colLabels)) -colours.reverse() -rows = len(data) +# Get some pastel shades for the colors +colors = plt.cm.BuPu(np.linspace(0, 0.5, len(columns))) +n_rows = len(data) -ind = arange(len(colLabels)) + 0.3 # the x locations for the groups -cellText = [] -width = 0.4 # the width of the bars -yoff = array([0.0] * len(colLabels)) # the bottom values for stacked bar chart -for row in range(rows): - bar(ind, data[row], width, bottom=yoff, color=colours[row]) - yoff = yoff + data[row] - cellText.append(['%1.1f' % (x/1000.0) for x in yoff]) +index = np.arange(len(columns)) + 0.3 +bar_width = 0.4 + +# Initialize the vertical-offset for the stacked bar chart. +y_offset = np.array([0.0] * len(columns)) + +# Plot bars and create text labels for the table +cell_text = [] +for row in range(n_rows): + plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row]) + y_offset = y_offset + data[row] + cell_text.append(['%1.1f' % (x/1000.0) for x in y_offset]) +# Reverse colors and text labels to display the last value at the top. +colors = colors[::-1] +cell_text.reverse() # Add a table at the bottom of the axes -colours.reverse() -cellText.reverse() -the_table = table(cellText=cellText, - rowLabels=rowLabels, rowColours=colours, - colLabels=colLabels, - loc='bottom') -ylabel("Loss $1000's") -vals = arange(0, 2500, 500) -yticks(vals*1000, ['%d' % val for val in vals]) -xticks([]) -title('Loss by Disaster') +the_table = plt.table(cellText=cell_text, + rowLabels=rows, + rowColours=colors, + colLabels=columns, + loc='bottom') + +# Adjust layout to make room for the table: +plt.subplots_adjust(left=0.2, bottom=0.2) + +plt.ylabel("Loss in ${0}'s".format(value_increment)) +plt.yticks(values * value_increment, ['%d' % val for val in values]) +plt.xticks([]) +plt.title('Loss by Disaster') -show() +plt.show() From 2c244671a0767d7e2a76c0ee107b8dd43d34c421 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Tue, 21 May 2013 00:55:17 -0500 Subject: [PATCH 3/6] Add streamplot function to screenshots doc --- doc/users/screenshots.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/users/screenshots.rst b/doc/users/screenshots.rst index caef5f9e0c74..69adf7c861a1 100644 --- a/doc/users/screenshots.rst +++ b/doc/users/screenshots.rst @@ -63,6 +63,21 @@ installs. .. _screenshots_ellipse_demo: +Streamplot +========== + +The :meth:`~matplotlib.pyplot.streamplot` function plots the streamlines of +a vector field. In addition to simply plotting the streamlines, it allows you +to map the colors and/or line widths of streamlines to a separate parameter, +such as the speed or local intensity of the vector field. + +.. plot:: mpl_examples/images_contours_and_fields/streamplot_demo_features.py + +This feature complements the :meth:`~matplotlib.pyplot.quiver` function for +plotting vector fields. Thanks to Tom Flannaghan and Tony Yu for adding the +streamplot function. + + Ellipses ======== From 40340fc6c821f8c9c00b2ff80e633ee97424318e Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Tue, 21 May 2013 13:12:26 -0400 Subject: [PATCH 4/6] Fixes a number of problems in the doc build. --- INSTALL | 12 ++--- doc/api/index.rst | 2 +- doc/api/markers_api.rst | 6 +-- doc/devel/release_guide.rst | 4 +- doc/users/github_stats.rst | 53 ++++++++++--------- doc/users/screenshots.rst | 10 +++- doc/users/whats_new.rst | 13 ++++- examples/lines_bars_and_markers/barh_demo.py | 1 - examples/pylab_examples/mathtext_examples.py | 46 ++-------------- .../artist_reference.py | 1 - lib/matplotlib/axes.py | 27 +++++----- lib/matplotlib/colorbar.py | 8 +-- lib/matplotlib/dates.py | 4 +- lib/matplotlib/lines.py | 2 +- lib/matplotlib/pyplot.py | 2 - lib/matplotlib/textpath.py | 6 +-- lib/mpl_toolkits/mplot3d/axes3d.py | 14 ++--- 17 files changed, 92 insertions(+), 119 deletions(-) diff --git a/INSTALL b/INSTALL index e43b117ebd0a..679f0c7ba191 100644 --- a/INSTALL +++ b/INSTALL @@ -183,7 +183,7 @@ the libraries themselves. `Download python `_. :term:`numpy` |minimum_numpy_version| (or later) - array support for python (`download `_) + array support for python (`download numpy `_) libpng 1.2 (or later) library for loading and saving :term:`PNG` files (`download @@ -201,7 +201,7 @@ libpng 1.2 (or later) easy_install or installing from source, the installer will attempt to download and install `python_dateutil` from PyPI. -:term:`pyparsing` +`pyparsing` Required for matplotlib's mathtext math rendering support. If using pip, easy_install or installing from source, the installer will attempt to download and install `pyparsing` from PyPI. @@ -216,9 +216,6 @@ backends and the capabilities they provide. :term:`tk` 8.3 or later The TCL/Tk widgets library used by the TkAgg backend -:term:`pyqt` 3.1 or later - The Qt3 widgets library python wrappers for the QtAgg backend - :term:`pyqt` 4.0 or later The Qt4 widgets library python wrappers for the Qt4Agg backend @@ -230,9 +227,6 @@ backends and the capabilities they provide. The python wrappers for the wx widgets library for use with the WX or WXAgg backend -:term:`pyfltk` 1.0 or later - The python wrappers of the FLTK widgets library for use with FLTKAgg - **Required libraries that ship with matplotlib** :term:`agg` 2.4 @@ -240,7 +234,7 @@ backends and the capabilities they provide. agg template source statically, so it will not affect anything on your system outside of matplotlib. -:term:`PyCXX` 6.2.4 +`PyCXX` 6.2.4 A library for writing Python extensions in C++. .. _build_osx: diff --git a/doc/api/index.rst b/doc/api/index.rst index 768e255aa229..1713b439c411 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -31,9 +31,9 @@ font_manager_api.rst gridspec_api.rst legend_api.rst + markers_api.rst mathtext_api.rst mlab_api.rst - nxutils_api.rst path_api.rst pyplot_api.rst sankey_api.rst diff --git a/doc/api/markers_api.rst b/doc/api/markers_api.rst index 7dfcb2eac38b..11e35f98638e 100644 --- a/doc/api/markers_api.rst +++ b/doc/api/markers_api.rst @@ -1,10 +1,10 @@ ******* -Markers* -****** +Markers +******* :mod:`matplotlib.markers` -======================== +========================= .. automodule:: matplotlib.markers :members: diff --git a/doc/devel/release_guide.rst b/doc/devel/release_guide.rst index 7e41f6b89e54..3cdc2740d6e8 100644 --- a/doc/devel/release_guide.rst +++ b/doc/devel/release_guide.rst @@ -1,8 +1,8 @@ .. _release-guide: -************************* +************************** Doing a matplotlib release -************************* +************************** A guide for developers who are doing a matplotlib release. diff --git a/doc/users/github_stats.rst b/doc/users/github_stats.rst index 7173cdb1984b..b6b4384a0185 100644 --- a/doc/users/github_stats.rst +++ b/doc/users/github_stats.rst @@ -1,5 +1,6 @@ .. _github-stats: + Github stats ============ @@ -102,7 +103,7 @@ The following 90 authors contributed 1618 commits. We closed a total of 1222 issues, 435 pull requests and 787 regular issues; -this is the full list (generated with the script +this is the full list (generated with the script :file:`tools/github_stats.py`): Pull Requests (435): @@ -151,7 +152,7 @@ Pull Requests (435): * :ghpull:`1762`: Make cbook safe to import while removing duplicate is_string_like; * :ghpull:`1252`: Properly passing on horiz-/vertOn to Cursor() * :ghpull:`1686`: Fix lost ticks -* :ghpull:`1640`: Fix bugs in legend positioning with loc='best' +* :ghpull:`1640`: Fix bugs in legend positioning with loc='best' * :ghpull:`1687`: Update lib/matplotlib/backends/backend_cairo.py * :ghpull:`1760`: Improved the subplot function documentation and fixed the autogeneration from boilerplate. * :ghpull:`1716`: PEP8 fixes on the figure module @@ -202,7 +203,7 @@ Pull Requests (435): * :ghpull:`1657`: Add EventCollection and eventplot * :ghpull:`1641`: PEP8 fixes on the rcsetup module * :ghpull:`1650`: _png.read_png crashes on Python 3 with urllib.request object -* :ghpull:`1568`: removed deprecated methods from the axes module. +* :ghpull:`1568`: removed deprecated methods from the axes module. * :ghpull:`1589`: Fix shifted ylabels (Issue #1571) * :ghpull:`1634`: add scatterpoints to rcParam * :ghpull:`1654`: added explicit 'zorder' kwarg to `Colection` and `LineCollection`. @@ -353,7 +354,7 @@ Pull Requests (435): * :ghpull:`1333`: PEP8 fixes on collections.py * :ghpull:`1336`: PEP8 fixes to colorbar.py * :ghpull:`1347`: Remove nonfunctioning cbook.isvector -* :ghpull:`1327`: plt.subplots: Set the visibility of the offset text to false on the shared axes. +* :ghpull:`1327`: plt.subplots: Set the visibility of the offset text to false on the shared axes. * :ghpull:`1335`: PEP8 fixes on cbook.py * :ghpull:`1334`: PEP8 fixes on blocking_input.py * :ghpull:`1332`: PEP8 fixes on cm.py @@ -371,7 +372,7 @@ Pull Requests (435): * :ghpull:`1285`: Hide Tk root window until later * :ghpull:`1305`: Fix pointer syntax error * :ghpull:`1294`: Update lib/mpl_toolkits/mplot3d/axes3d.py -* :ghpull:`1300`: Pcolormesh and colorbar documentation. +* :ghpull:`1300`: Pcolormesh and colorbar documentation. * :ghpull:`1296`: Make Container._remove_method call correctly * :ghpull:`1293`: Fixed to contour to support the _as_mpl_transform api. * :ghpull:`1284`: Fix Image Tutorial: plt.imshow instead of mpimg.imshow. @@ -383,7 +384,7 @@ Pull Requests (435): * :ghpull:`1277`: Fixed bug in MaxNLocator.bin_boundaries * :ghpull:`1273`: Handled baseline image folder identification for non matplotlib projects... * :ghpull:`1230`: Fix dpi issue for bitmaps on the OS X backend -* :ghpull:`1251`: backend_pgf. Enable custom dashstyles in the pgf backend +* :ghpull:`1251`: backend_pgf. Enable custom dashstyles in the pgf backend * :ghpull:`1264`: Re-added the matplotlib.dates import on axes * :ghpull:`1271`: Set axis limits in test_stackplot * :ghpull:`1269`: Fix typo in docstring @@ -406,7 +407,7 @@ Pull Requests (435): * :ghpull:`1231`: fix Typesetting in plot() docstring * :ghpull:`1215`: PEP8 on lib/matplotlib.afm.py * :ghpull:`1216`: PEP8 fixes on the animation module -* :ghpull:`1208`: FAIL: matplotlib.tests.test_text.test_contains.test +* :ghpull:`1208`: FAIL: matplotlib.tests.test_text.test_contains.test * :ghpull:`1209`: Pass linewidth to Mac context properly * :ghpull:`847`: Add stacked kwarg to hist and implement stacked hists for step histtype * :ghpull:`1228`: backend_pgf: pep8 edits @@ -469,7 +470,7 @@ Pull Requests (435): * :ghpull:`983`: Issues with dateutil and pytz * :ghpull:`1133`: figure.py: import warnings, and make imports absolute * :ghpull:`1132`: clean out obsolete matplotlibrc-related bits to close #1123 -* :ghpull:`1131`: Cleanup after the gca test. +* :ghpull:`1131`: Cleanup after the gca test. * :ghpull:`563`: sankey.add() has mutable defaults * :ghpull:`731`: Plot limit with transform * :ghpull:`1107`: Added %s support for labels. @@ -526,7 +527,7 @@ Pull Requests (435): * :ghpull:`898`: Added warnings for easily confusable subplot/subplots invocations * :ghpull:`963`: Add detection of file extension for file-like objects * :ghpull:`973`: Fix sankey.py pep8 and py3 compatibility -* :ghpull:`972`: Force closing PIL image files +* :ghpull:`972`: Force closing PIL image files * :ghpull:`981`: Fix pathpatch3d_demo.py on Python 3 * :ghpull:`980`: Fix basic_units.py on Python 3. PEP8 and PyLint cleanup. * :ghpull:`1014`: qt4: remove duplicate file save button; and remove trailing whitespace @@ -540,7 +541,7 @@ Pull Requests (435): * :ghpull:`851`: Simple GUI interface enhancements * :ghpull:`979`: Fix test_mouseclicks.py on Python 3 * :ghpull:`977`: Fix lasso_selector_demo.py on Python 3 -* :ghpull:`970`: Fix tiff and jpeg export via PIL +* :ghpull:`970`: Fix tiff and jpeg export via PIL * :ghpull:`961`: Issue 807 auto minor locator Issues (787): @@ -632,7 +633,7 @@ Issues (787): * :ghissue:`1252`: Properly passing on horiz-/vertOn to Cursor() * :ghissue:`1632`: Fix build on Ubuntu 12.10 * :ghissue:`1686`: Fix lost ticks -* :ghissue:`1640`: Fix bugs in legend positioning with loc='best' +* :ghissue:`1640`: Fix bugs in legend positioning with loc='best' * :ghissue:`1687`: Update lib/matplotlib/backends/backend_cairo.py * :ghissue:`1760`: Improved the subplot function documentation and fixed the autogeneration from boilerplate. * :ghissue:`1647`: WIP: Deprecation of the cbook module @@ -725,7 +726,7 @@ Issues (787): * :ghissue:`1657`: Add EventCollection and eventplot * :ghissue:`1641`: PEP8 fixes on the rcsetup module * :ghissue:`1650`: _png.read_png crashes on Python 3 with urllib.request object -* :ghissue:`1568`: removed deprecated methods from the axes module. +* :ghissue:`1568`: removed deprecated methods from the axes module. * :ghissue:`1571`: Y-labels shifted * :ghissue:`1589`: Fix shifted ylabels (Issue #1571) * :ghissue:`1276`: Fix overwriting suptitle @@ -748,7 +749,7 @@ Issues (787): * :ghissue:`1582`: Linear tri interpolator * :ghissue:`1637`: change cbook to relative import * :ghissue:`1645`: add get_segments method to collections.LineCollection - updated -* :ghissue:`1639`: Rename web_static to web_backend in setup.py +* :ghissue:`1639`: Rename web_static to web_backend in setup.py * :ghissue:`1618`: Mplot3d/crashfixes * :ghissue:`1636`: hexbin log scale is broken in matplotlib 1.2.0 * :ghissue:`1624`: implemented inverse transform for Mollweide axes @@ -756,13 +757,13 @@ Issues (787): * :ghissue:`1139`: Make Axes.stem take at least one argument. * :ghissue:`1426`: WebAgg backend * :ghissue:`1606`: Document the C/C++ code guidelines -* :ghissue:`1622`: zorder is not respected by all parts of `errorbar` +* :ghissue:`1622`: zorder is not respected by all parts of `errorbar` * :ghissue:`1628`: Fix errorbar zorder v1.2 * :ghissue:`1625`: saving pgf to a stream is not supported * :ghissue:`1588`: Annotations appear in incorrect locations * :ghissue:`1620`: Fix bug in _AnnotationBase * :ghissue:`1621`: Package for python 3.3 on OS X -* :ghissue:`1616`: Legend: Also calc the bbox of the legend when the frame is not drawn. +* :ghissue:`1616`: Legend: Also calc the bbox of the legend when the frame is not drawn. * :ghissue:`1587`: Mac OS X 10.5 needs an autoreleasepool here to avoid memory leaks. Newer... * :ghissue:`1597`: new MatplotlibDeprecationWarning class (against master) * :ghissue:`1596`: new MatplotlibDeprecationWarning class (against 1.2.x) @@ -918,7 +919,7 @@ Issues (787): * :ghissue:`1424`: pcolor fails if edgecolors is not a string * :ghissue:`1427`: Fix AttrituteError for .lower on tuple of strings * :ghissue:`1425`: Rebase of #1418 on v1.2.x -* :ghissue:`1418`: Tables: Fix get_window_extent for table +* :ghissue:`1418`: Tables: Fix get_window_extent for table * :ghissue:`1411`: Fix transparent markers in PDF backend. Closes #1410 * :ghissue:`1410`: Open markers incorrect in PDF output * :ghissue:`1416`: backend_pdf: optional rgbFace arg in fillp replaces code in draw_markers. Closes #1410 @@ -981,7 +982,7 @@ Issues (787): * :ghissue:`1333`: PEP8 fixes on collections.py * :ghissue:`1336`: PEP8 fixes to colorbar.py * :ghissue:`1347`: Remove nonfunctioning cbook.isvector -* :ghissue:`1327`: plt.subplots: Set the visibility of the offset text to false on the shared axes. +* :ghissue:`1327`: plt.subplots: Set the visibility of the offset text to false on the shared axes. * :ghissue:`1335`: PEP8 fixes on cbook.py * :ghissue:`1334`: PEP8 fixes on blocking_input.py * :ghissue:`1332`: PEP8 fixes on cm.py @@ -1005,7 +1006,7 @@ Issues (787): * :ghissue:`156`: Multicursor not displayed with zoom on * :ghissue:`1320`: Cursor widget now uses widgetlock; closes Issue #156 * :ghissue:`1321`: pgf backend. Y-labels in subplot are not alligned after baseline but bottom of letter -* :ghissue:`1301`: Colorbar Add kw arguement to colorbar to reenable edges around faces +* :ghissue:`1301`: Colorbar Add kw arguement to colorbar to reenable edges around faces * :ghissue:`1315`: Add documentation of colorbar issue #1188 to colorbar documentation. * :ghissue:`1303`: twinx/twiny misses settings axes * :ghissue:`1307`: Marker not round with markersize=3 @@ -1017,8 +1018,8 @@ Issues (787): * :ghissue:`1294`: Update lib/mpl_toolkits/mplot3d/axes3d.py * :ghissue:`159`: Autoscale in hist() with step and log * :ghissue:`167`: windows x64 support in _tkagg.so -* :ghissue:`1300`: Pcolormesh and colorbar documentation. -* :ghissue:`1178`: Make colorbar draw edge with facecolor around the faces. +* :ghissue:`1300`: Pcolormesh and colorbar documentation. +* :ghissue:`1178`: Make colorbar draw edge with facecolor around the faces. * :ghissue:`1205`: New 'gridon' keyword in plotfile * :ghissue:`1295`: Exception when using Container.remove * :ghissue:`1296`: Make Container._remove_method call correctly @@ -1052,7 +1053,7 @@ Issues (787): * :ghissue:`1273`: Handled baseline image folder identification for non matplotlib projects... * :ghissue:`1230`: Fix dpi issue for bitmaps on the OS X backend * :ghissue:`1274`: backend_pgf: Custom dashstyles and consistency with other backends -* :ghissue:`1251`: backend_pgf. Enable custom dashstyles in the pgf backend +* :ghissue:`1251`: backend_pgf. Enable custom dashstyles in the pgf backend * :ghissue:`1264`: Re-added the matplotlib.dates import on axes * :ghissue:`1271`: Set axis limits in test_stackplot * :ghissue:`1269`: Fix typo in docstring @@ -1086,7 +1087,7 @@ Issues (787): * :ghissue:`1231`: fix Typesetting in plot() docstring * :ghissue:`1215`: PEP8 on lib/matplotlib.afm.py * :ghissue:`1216`: PEP8 fixes on the animation module -* :ghissue:`1208`: FAIL: matplotlib.tests.test_text.test_contains.test +* :ghissue:`1208`: FAIL: matplotlib.tests.test_text.test_contains.test * :ghissue:`786`: savefig() renders paths and text differently than show() * :ghissue:`1209`: Pass linewidth to Mac context properly * :ghissue:`847`: Add stacked kwarg to hist and implement stacked hists for step histtype @@ -1179,7 +1180,7 @@ Issues (787): * :ghissue:`1141`: backend_pgf: fix parentheses typo * :ghissue:`1114`: Make grid accept alpha rcParam * :ghissue:`1118`: ERROR: matplotlib.tests.test_backend_pgf.test_pdflatex on Python 3.x -* :ghissue:`1116`: ERROR: matplotlib.tests.test_backend_pgf.test_xelatex +* :ghissue:`1116`: ERROR: matplotlib.tests.test_backend_pgf.test_xelatex * :ghissue:`1124`: PGF backend, fix #1116, #1118 and #1128 * :ghissue:`745`: Cannot run tests with Python 3.x on MacOS 10.7 * :ghissue:`983`: Issues with dateutil and pytz @@ -1188,7 +1189,7 @@ Issues (787): * :ghissue:`1133`: figure.py: import warnings, and make imports absolute * :ghissue:`1123`: Rationalize the number of ancillary (default matplotlibrc) files * :ghissue:`1132`: clean out obsolete matplotlibrc-related bits to close #1123 -* :ghissue:`1131`: Cleanup after the gca test. +* :ghissue:`1131`: Cleanup after the gca test. * :ghissue:`563`: sankey.add() has mutable defaults * :ghissue:`238`: patch for qt4 backend * :ghissue:`731`: Plot limit with transform @@ -1298,7 +1299,7 @@ Issues (787): * :ghissue:`898`: Added warnings for easily confusable subplot/subplots invocations * :ghissue:`963`: Add detection of file extension for file-like objects * :ghissue:`973`: Fix sankey.py pep8 and py3 compatibility -* :ghissue:`972`: Force closing PIL image files +* :ghissue:`972`: Force closing PIL image files * :ghissue:`981`: Fix pathpatch3d_demo.py on Python 3 * :ghissue:`980`: Fix basic_units.py on Python 3. PEP8 and PyLint cleanup. * :ghissue:`996`: macosx backend broken by #901: QuadMesh fails so colorbar fails @@ -1322,7 +1323,7 @@ Issues (787): * :ghissue:`851`: Simple GUI interface enhancements * :ghissue:`979`: Fix test_mouseclicks.py on Python 3 * :ghissue:`977`: Fix lasso_selector_demo.py on Python 3 -* :ghissue:`970`: Fix tiff and jpeg export via PIL +* :ghissue:`970`: Fix tiff and jpeg export via PIL * :ghissue:`707`: key_press_event in pyqt4 embedded matplotlib * :ghissue:`243`: Debug version/symbols for win32 * :ghissue:`255`: Classes in _transforms.h in global namespace diff --git a/doc/users/screenshots.rst b/doc/users/screenshots.rst index 69adf7c861a1..2f9b04443300 100644 --- a/doc/users/screenshots.rst +++ b/doc/users/screenshots.rst @@ -103,7 +103,7 @@ command, which includes customizations such as error bars: It's also simple to create stacked bars (`bar_stacked.py `_), candlestick bars -(`bar_stacked.py `_), +(`finance_demo.py `_), and horizontal bar charts (`barh_demo.py `_). @@ -296,3 +296,11 @@ For examples of how to embed matplotlib in different toolkits, see: * :ref:`user_interfaces-mpl_with_glade` * :ref:`user_interfaces-embedding_in_qt` * :ref:`user_interfaces-embedding_in_tk` + +XKCD-style sketch plots +======================= + +matplotlib supports plotting in the style of `xkcd +`. + +.. plot:: mpl_examples/showcase/xkcd.py diff --git a/doc/users/whats_new.rst b/doc/users/whats_new.rst index 381dbd1f1ef6..2c5f6d58c3cb 100644 --- a/doc/users/whats_new.rst +++ b/doc/users/whats_new.rst @@ -30,6 +30,17 @@ not been in a working state for a long time have been removed. Highlights include removing the Qt version 3 backends, and the FltkAgg and Emf backends. See :ref:`changes_in_1_3` for a complete list. +New setup script +---------------- + +matplotlib 1.3 includes an entirely rewritten setup script. We now +ship fewer dependencies with the tarballs and installers themselves. +Notably, `pytz`, `dateutil` and `pyparsing` are no longer included +with matplotlib. You can either install them manually first, or let +`pip` install them as depdencies along with matplotlib. It is now +possible to not include certain subcomponents, such as the unit test +data, in the install. See `setup.cfg.template` for more information. + `xkcd`-style sketch plotting ---------------------------- @@ -48,7 +59,7 @@ Michael Droettboom, Phil Elson and others have developed a new backend, WebAgg, to display figures in a web browser. It works with animations as well as being fully interactive. -.. image:: _static/webagg_screenshot.png +.. image:: /_static/webagg_screenshot.png Future versions of matplotlib will integrate this backend with the IPython notebook for a fully web browser based plotting frontend. diff --git a/examples/lines_bars_and_markers/barh_demo.py b/examples/lines_bars_and_markers/barh_demo.py index b0087acb1eb3..2016824cc2ad 100644 --- a/examples/lines_bars_and_markers/barh_demo.py +++ b/examples/lines_bars_and_markers/barh_demo.py @@ -2,7 +2,6 @@ Simple demo of a horizontal bar chart. """ import matplotlib.pyplot as plt; plt.rcdefaults() -from mpltools import style; style.use('gallery') import numpy as np import matplotlib.pyplot as plt diff --git a/examples/pylab_examples/mathtext_examples.py b/examples/pylab_examples/mathtext_examples.py index d71c47fb50b4..6437b61a100f 100755 --- a/examples/pylab_examples/mathtext_examples.py +++ b/examples/pylab_examples/mathtext_examples.py @@ -7,51 +7,15 @@ import gc stests = [ - r'$a+b+\dots+\dot{s}+\ldots$', - r'$x \doteq y$', - r'\$100.00 $\alpha \_$', - r'$\frac{\$100.00}{y}$', - r'$x y$', - r'$x+y\ x=y\ x>> text(x, y, s, bbox=dict(facecolor='red', alpha=0.5)) - """ default = { 'verticalalignment': 'baseline', @@ -4634,7 +4637,7 @@ def legend(self, *args, **kwargs): Users can specify any arbitrary location for the legend using the *bbox_to_anchor* keyword argument. bbox_to_anchor can be an instance of BboxBase(or its derivatives) or a tuple of 2 or 4 floats. - For example, + For example:: loc = 'upper right', bbox_to_anchor = (0.5, 0.5) @@ -4647,7 +4650,6 @@ def legend(self, *args, **kwargs): The loc itslef can be a 2-tuple giving x,y of the lower-left corner of the legend in axes coords (*bbox_to_anchor* is ignored). - Keyword arguments: *prop*: [ *None* | FontProperties | dict ] @@ -8070,6 +8072,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None, If an integer is given, `bins + 1` bin edges are returned, consistently with :func:`numpy.histogram` for numpy version >= 1.3. + Unequally spaced bins are supported if `bins` is a sequence. range : tuple, optional, default: None @@ -8158,7 +8161,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None, Returns ------- - (n, bins, patches) or ([n0, n1, ...], bins, [patches0, patches1,...]) + tuple : (n, bins, patches) or ([n0, n1, ...], bins, [patches0, patches1,...]) Other Parameters ---------------- @@ -8173,7 +8176,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None, Until numpy release 1.5, the underlying numpy histogram function was incorrect with `normed`=`True` if bin sizes were unequal. MPL inherited that error. It is now corrected within MPL when using - earlier numpy versions + earlier numpy versions. Examples -------- diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index 5a6678036b44..dc988db47b22 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -970,14 +970,14 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15, Keyword arguments may include the following (with defaults): - *location*: [**None**|'left'|'right'|'top'|'bottom'] + location : [`None`|'left'|'right'|'top'|'bottom'] The position, relative to **parents**, where the colorbar axes should be created. If None, the value will either come from the - given **orientation**, else it will default to 'right'. + given `orientation`, else it will default to 'right'. - *orientation*: [**None**|'vertical'|'horizontal'] + orientation : [`None`|'vertical'|'horizontal'] The orientation of the colorbar. Typically, this keyword shouldn't - be used, as it can be derived from the **location** keyword. + be used, as it can be derived from the `location` keyword. %s diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index d770e7c793d6..d09589b7b776 100755 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -9,13 +9,13 @@ easy conversion to and from :mod:`datetime` and numeric ranges. .. note:: + Like Python's datetime, mpl uses the Gregorian calendar for all conversions between dates and floating point numbers. This practice is not universal, and calendar differences can cause confusing differences between what Python and mpl give as the number of days since 0001-01-01 and what other software and databases yield. For example, the `US Naval Observatory - `_ + `_ uses a calendar that switches from Julian to Gregorian in October, 1582. Hence, using their calculator, the number of days between 0001-01-01 and 2006-04-01 is 732403, whereas using the Gregorian calendar via the datetime diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index c9f256fb97f4..be80b499b7c2 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -703,7 +703,7 @@ def get_data(self, orig=True): """ Return the xdata, ydata. - If *orig* is *True*, return the original data + If *orig* is *True*, return the original data. """ return self.get_xdata(orig=orig), self.get_ydata(orig=orig) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index fd9a5c6b0c91..95dc9e17047b 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1264,8 +1264,6 @@ def box(on=None): def title(s, *args, **kwargs): """ - title(label, fontdict=None, loc='center', **kwargs) - Set a title of the current axes. Set one of the three available axes titles. The available titles are diff --git a/lib/matplotlib/textpath.py b/lib/matplotlib/textpath.py index 35634092cf83..5d3c57643739 100644 --- a/lib/matplotlib/textpath.py +++ b/lib/matplotlib/textpath.py @@ -435,9 +435,9 @@ def __init__(self, xy, s, size=None, prop=None, prop, s, usetex=usetex) - self.should_simplify = False - self.simplify_threshold = rcParams['path.simplify_threshold'] - self.has_nonfinite = False + self._should_simplify = False + self._simplify_threshold = rcParams['path.simplify_threshold'] + self._has_nonfinite = False self._interpolation_steps = _interpolation_steps def set_size(self, size): diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 444a952abfee..8e75259db533 100755 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -464,7 +464,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True, .. versionchanged :: 1.1.0 Function signature was changed to better match the 2D version. *tight* is now explicitly a kwarg and placed first. - + .. versionchanged :: 1.2.1 This is now fully functional. @@ -668,7 +668,7 @@ def set_zlim3d(self, bottom=None, top=None, emit=True, auto=False, **kw): Set 3D z limits. See :meth:`matplotlib.axes.Axes.set_ylim` for full documentation - + """ if 'zmin' in kw: bottom = kw.pop('zmin') @@ -752,7 +752,7 @@ def get_zscale(self) : # We need to slightly redefine these to pass scalez=False # to their calls of autoscale_view. def set_xscale(self, value, **kwargs) : - self.xaxis.set_scale(value, **kwargs) + self.xaxis._set_scale(value, **kwargs) self.autoscale_view(scaley=False, scalez=False) self._update_transScale() set_xscale.__doc__ = maxes.Axes.set_xscale.__doc__ + """ @@ -762,7 +762,7 @@ def set_xscale(self, value, **kwargs) : """ def set_yscale(self, value, **kwargs) : - self.yaxis.set_scale(value, **kwargs) + self.yaxis._set_scale(value, **kwargs) self.autoscale_view(scalex=False, scalez=False) self._update_transScale() set_yscale.__doc__ = maxes.Axes.set_yscale.__doc__ + """ @@ -793,7 +793,7 @@ def set_zscale(self, value, **kwargs) : .. versionadded :: 1.1.0 This function was added, but not tested. Please report any bugs. """ - self.zaxis.set_scale(value, **kwargs) + self.zaxis._set_scale(value, **kwargs) self.autoscale_view(scalex=False, scaley=False) self._update_transScale() @@ -1035,9 +1035,9 @@ def cla(self): self.zaxis.minor = self._sharez.zaxis.minor z0, z1 = self._sharez.get_zlim() self.set_zlim(z0, z1, emit=False, auto=None) - self.zaxis.set_scale(self._sharez.zaxis.get_scale()) + self.zaxis._set_scale(self._sharez.zaxis.get_scale()) else: - self.zaxis.set_scale('linear') + self.zaxis._set_scale('linear') self._autoscaleZon = True self._zmargin = 0 From 22613d2691a17b76706526519272671f0ac4a584 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 22 May 2013 09:01:04 -0400 Subject: [PATCH 5/6] double backticks --- lib/matplotlib/colorbar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index dc988db47b22..90aa983c51eb 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -973,11 +973,11 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15, location : [`None`|'left'|'right'|'top'|'bottom'] The position, relative to **parents**, where the colorbar axes should be created. If None, the value will either come from the - given `orientation`, else it will default to 'right'. + given ``orientation``, else it will default to 'right'. orientation : [`None`|'vertical'|'horizontal'] The orientation of the colorbar. Typically, this keyword shouldn't - be used, as it can be derived from the `location` keyword. + be used, as it can be derived from the ``location`` keyword. %s From f9b1a9aa2814f0ed8d968ed60ec06f89ac03c159 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 22 May 2013 10:22:07 -0400 Subject: [PATCH 6/6] Remove long URL --- lib/matplotlib/dates.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index d09589b7b776..a0f74d3842c3 100755 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -10,15 +10,15 @@ .. note:: - Like Python's datetime, mpl uses the Gregorian calendar for all conversions - between dates and floating point numbers. This practice is not universal, - and calendar differences can cause confusing differences between what - Python and mpl give as the number of days since 0001-01-01 and what other - software and databases yield. For example, the `US Naval Observatory - `_ - uses a calendar that switches from Julian to Gregorian in October, 1582. - Hence, using their calculator, the number of days between 0001-01-01 and - 2006-04-01 is 732403, whereas using the Gregorian calendar via the datetime + Like Python's datetime, mpl uses the Gregorian calendar for all + conversions between dates and floating point numbers. This practice + is not universal, and calendar differences can cause confusing + differences between what Python and mpl give as the number of days + since 0001-01-01 and what other software and databases yield. For + example, the US Naval Observatory uses a calendar that switches + from Julian to Gregorian in October, 1582. Hence, using their + calculator, the number of days between 0001-01-01 and 2006-04-01 is + 732403, whereas using the Gregorian calendar via the datetime module we find:: In [31]:date(2006,4,1).toordinal() - date(1,1,1).toordinal()