Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a80cf6

Browse filesBrowse files
authored
Merge pull request #8581 from choldgraf/front_thumbnails
linking front thumbnails, updating screenshots + pyplot API page
2 parents f0ccf7e + cf76980 commit 9a80cf6
Copy full SHA for 9a80cf6

File tree

Expand file treeCollapse file tree

9 files changed

+186
-145
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+186
-145
lines changed

‎doc/_templates/index.html

Copy file name to clipboardExpand all lines: doc/_templates/index.html
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ <h1>Introduction</h1>
5555
interface toolkits.</p>
5656

5757
<div class="responsive_screenshots">
58-
<a a href="{{ pathto('users/screenshots') }}">
58+
<a a href="{{ pathto('tutorials/01_introductory/sample_plots') }}">
5959
<div class="responsive_subfig">
60-
<img align="middle", src="{{ pathto('_static/membrane_frontpage.png', 1) }}", border="0", alt="screenshots"/>
60+
<img align="middle", src="{{ pathto('_images/sphx_glr_membrane_thumb.png', 1) }}", border="0", alt="screenshots"/>
6161
</div>
6262
<div class="responsive_subfig">
63-
<img align="middle", src="{{ pathto('_static/histogram_frontpage.png', 1) }}", border="0", alt="screenshots"/>
63+
<img align="middle", src="{{ pathto('_images/sphx_glr_histogram_thumb1.png', 1) }}", border="0", alt="screenshots"/>
6464
</div>
6565
<div class="responsive_subfig">
66-
<img align="middle", src="{{ pathto('_static/contour_frontpage.png', 1) }}", border="0", alt="screenshots"/>
66+
<img align="middle", src="{{ pathto('_images/sphx_glr_contour_thumb.png', 1) }}", border="0", alt="screenshots"/>
6767
</div>
6868
<div class="responsive_subfig">
69-
<img align="middle", src="{{ pathto('_static/surface3d_frontpage.png', 1) }}", border="0", alt="screenshots"/>
69+
<img align="middle", src="{{ pathto('_images/sphx_glr_3D_thumb.png', 1) }}", border="0", alt="screenshots"/>
7070
</div>
7171
</a>
7272
</div>
@@ -75,8 +75,8 @@ <h1>Introduction</h1>
7575
<p>Matplotlib tries to make easy things easy and hard things possible.
7676
You can generate plots, histograms, power spectra, bar charts,
7777
errorcharts, scatterplots, etc., with just a few lines of code.
78-
For a example, see the <a href="{{ pathto('users/screenshots')
79-
}}">screenshots</a> and <a href="{{ pathto('gallery/index') }}">thumbnail</a> gallery.</p>
78+
For examples, see the <a href="{{ pathto('tutorials/01_introductory/sample_plots')
79+
}}">sample plots</a> and <a href="{{ pathto('gallery/index') }}">thumbnail</a> gallery.</p>
8080

8181
<p>For simple plotting the <tt>pyplot</tt> module provides a
8282
MATLAB-like interface, particularly when combined

‎doc/api/pyplot_summary.rst

Copy file name to clipboard
+37-2Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,43 @@
1-
Plotting commands summary
2-
=========================
1+
Below we describe several common approaches to plotting with Matplotlib.
2+
3+
.. contents::
4+
5+
The Pyplot API
6+
--------------
7+
8+
The :mod:`matplotlib.pyplot` module contains functions that allow you to generate
9+
many kinds of plots quickly. For examples that showcase the use
10+
of the :mod:`matplotlib.pyplot` module, see the
11+
:ref:`sphx_glr_tutorials_01_introductory_pyplot.py`
12+
or the :ref:`pyplots_examples`. We also recommend that you look into
13+
the object-oriented approach to plotting, described below.
314

415
.. currentmodule:: matplotlib.pyplot
516

617
.. autofunction:: plotting
718

19+
The Object-Oriented API
20+
-----------------------
21+
22+
Most of these functions also exist as methods in the
23+
:class:`matplotlib.axes.Axes` class. You can use them with the
24+
"Object Oriented" approach to Matplotlib.
25+
26+
While it is easy to quickly generate plots with the
27+
:mod:`matplotlib.pyplot` module,
28+
we recommend using the object-oriented approach for more control
29+
and customization of your plots. See the methods in the
30+
:meth:`matplotlib.axes.Axes` class for many of the same plotting functions.
31+
For examples of the OO approach to Matplotlib, see the
32+
:ref:`API Examples<api_examples>`.
33+
34+
Colors in Matplotlib
35+
--------------------
36+
37+
There are many colormaps you can use to map data onto color values.
38+
Below we list several ways in which color can be utilized in Matplotlib.
39+
40+
For a more in-depth look at colormaps, see the
41+
:ref:`sphx_glr_tutorials_colors_colormaps.py` tutorial.
42+
843
.. autofunction:: colormaps

‎doc/contents.rst

Copy file name to clipboardExpand all lines: doc/contents.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Overview
1515
:maxdepth: 2
1616

1717
users/index.rst
18-
api/index.rst
1918
faq/index.rst
2019
mpl_toolkits/index.rst
2120
resources/index.rst
2221
thirdpartypackages/index.rst
22+
api/index.rst
2323
devel/index.rst
2424
glossary/index.rst
2525

‎doc/make.py

Copy file name to clipboardExpand all lines: doc/make.py
-44Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -52,45 +52,6 @@ def linkcheck():
5252
[sys.executable]
5353
+ '-msphinx -b linkcheck -d build/doctrees . build/linkcheck'.split())
5454

55-
56-
# For generating PNGs of the top row of index.html:
57-
FRONTPAGE_PY_PATH = "../examples/frontpage/" # python scripts location
58-
FRONTPAGE_PNG_PATH = "_static/" # png files location
59-
# png files and corresponding generation scripts:
60-
FRONTPAGE_PNGS = {"surface3d_frontpage.png": "3D.py",
61-
"contour_frontpage.png": "contour.py",
62-
"histogram_frontpage.png": "histogram.py",
63-
"membrane_frontpage.png": "membrane.py"}
64-
65-
66-
def generate_frontpage_pngs(only_if_needed=True):
67-
"""Executes the scripts for PNG generation of the top row of index.html.
68-
69-
If `only_if_needed` is `True`, then the PNG file is only generated, if it
70-
doesn't exist or if the python file is newer.
71-
72-
Note that the element `div.responsive_screenshots` in the file
73-
`_static/mpl.css` has the height and cumulative width of the used PNG files
74-
as attributes. This ensures that the magnification of those PNGs is <= 1.
75-
"""
76-
for fn_png, fn_py in FRONTPAGE_PNGS.items():
77-
pn_png = os.path.join(FRONTPAGE_PNG_PATH, fn_png) # get full paths
78-
pn_py = os.path.join(FRONTPAGE_PY_PATH, fn_py)
79-
80-
# Read file modification times:
81-
mtime_py = os.path.getmtime(pn_py)
82-
mtime_png = (os.path.getmtime(pn_png) if os.path.exists(pn_png) else
83-
mtime_py - 1) # set older time, if file doesn't exist
84-
85-
if only_if_needed and mtime_py <= mtime_png:
86-
continue # do nothing if png is newer
87-
88-
# Execute python as subprocess (preferred over os.system()):
89-
subprocess.check_call(
90-
[sys.executable, pn_py]) # raises CalledProcessError()
91-
os.rename(fn_png, pn_png) # move file to _static/ directory
92-
93-
9455
DEPSY_PATH = "_static/depsy_badge.svg"
9556
DEPSY_URL = "http://depsy.org/api/package/pypi/matplotlib/badge.svg"
9657
DEPSY_DEFAULT = "_static/depsy_badge_default.svg"
@@ -121,7 +82,6 @@ def fetch_depsy_badge():
12182
def html(buildername='html'):
12283
"""Build Sphinx 'html' target. """
12384
check_build()
124-
generate_frontpage_pngs()
12585
fetch_depsy_badge()
12686

12787
rc = '../lib/matplotlib/mpl-data/matplotlibrc'
@@ -213,10 +173,6 @@ def clean():
213173
for filename in glob.glob(pattern):
214174
if os.path.exists(filename):
215175
os.remove(filename)
216-
for fn in FRONTPAGE_PNGS.keys(): # remove generated PNGs
217-
pn = os.path.join(FRONTPAGE_PNG_PATH, fn)
218-
if os.path.exists(pn):
219-
os.remove(os.path.join(pn))
220176

221177

222178
def build_all():

‎doc/users/examples_index.rst

Copy file name to clipboardExpand all lines: doc/users/examples_index.rst
-7Lines changed: 0 additions & 7 deletions
This file was deleted.

‎doc/users/index.rst

Copy file name to clipboardExpand all lines: doc/users/index.rst
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ User's Guide
1515
intro.rst
1616
installing.rst
1717
interactive.rst
18-
examples_index
1918
whats_new.rst
2019
github_stats.rst
2120
license.rst
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
==============================
3+
Plotting categorical variables
4+
==============================
5+
6+
How to use categorical variables in Matplotlib.
7+
8+
Many times you want to create a plot that uses categorical variables
9+
in Matplotlib. Matplotlib allows you to pass categorical variables directly to
10+
many plotting functions, which we demonstrate below.
11+
"""
12+
import matplotlib.pyplot as plt
13+
14+
data = {'apples': 10, 'oranges': 15, 'lemons': 5, 'limes': 20}
15+
names = list(data.keys())
16+
values = list(data.values())
17+
18+
fig, axs = plt.subplots(1, 3, figsize=(9, 3), sharey=True)
19+
axs[0].bar(names, values)
20+
axs[1].scatter(names, values)
21+
axs[2].plot(names, values)
22+
fig.suptitle('Categorical Plotting')
23+
24+
25+
###############################################################################
26+
# This works on both axes:
27+
28+
cat = ["bored", "happy", "bored", "bored", "happy", "bored"]
29+
dog = ["happy", "happy", "happy", "happy", "bored", "bored"]
30+
activity = ["combing", "drinking", "feeding", "napping", "playing", "washing"]
31+
32+
fig, ax = plt.subplots()
33+
ax.plot(activity, dog, label="dog")
34+
ax.plot(activity, cat, label="cat")
35+
ax.legend()
36+
37+
plt.show()

‎tutorials/01_introductory/pyplot.py

Copy file name to clipboardExpand all lines: tutorials/01_introductory/pyplot.py
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,30 @@
118118
plt.ylabel('entry b')
119119
plt.show()
120120

121+
###############################################################################
122+
# .. _plotting-with-categorical-vars:
123+
#
124+
# Plotting with categorical variables
125+
# ===================================
126+
#
127+
# It is also possible to create a plot using categorical variables.
128+
# Matplotlib allows you to pass categorical variables directly to
129+
# many plotting functions. For example:
130+
131+
names = ['group_a', 'group_b', 'group_c']
132+
values = [1, 10, 100]
133+
134+
plt.figure(1, figsize=(9, 3))
135+
136+
plt.subplot(131)
137+
plt.bar(names, values)
138+
plt.subplot(132)
139+
plt.scatter(names, values)
140+
plt.subplot(133)
141+
plt.plot(names, values)
142+
plt.suptitle('Categorical Plotting')
143+
plt.show()
144+
121145
###############################################################################
122146
# .. _controlling-line-properties:
123147
#

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.