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

Skip to content

Backport PR #25019 on branch v3.7.x (Tweak titles pyplot examples.) #25029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ per-file-ignores =
tutorials/introductory/quick_start.py: E703
tutorials/introductory/animation_tutorial.py: E501
tutorials/text/annotations.py: E402, E501
tutorials/text/mathtext.py: E501
tutorials/text/text_intro.py: E402
tutorials/text/text_props.py: E501
tutorials/text/usetex.py: E501
Expand Down
1 change: 1 addition & 0 deletions examples/pyplots/axline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

`~.axes.Axes.axline` draws infinite straight lines in arbitrary directions.
"""

import numpy as np
import matplotlib.pyplot as plt

Expand Down
30 changes: 0 additions & 30 deletions examples/pyplots/pyplot_mathtext.py

This file was deleted.

12 changes: 6 additions & 6 deletions examples/pyplots/pyplot_simple.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
=============
Pyplot Simple
=============
===========
Simple plot
===========

A very simple pyplot where a list of numbers are plotted against their
index. Creates a straight line due to the rate of change being 1 for
both the X and Y axis. Use a format string (here, 'o-r') to set the
A simple plot where a list of numbers are plotted against their index,
resulting in a straight line. Use a format string (here, 'o-r') to set the
markers (circles), linestyle (solid line) and color (red).

.. redirect-from:: /gallery/pyplots/fig_axes_labels_simple
.. redirect-from:: /gallery/pyplots/pyplot_formatstr
"""

import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4], 'o-r')
Expand Down
38 changes: 19 additions & 19 deletions examples/pyplots/pyplot_text.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
"""
===========
Pyplot Text
===========
==============================
Text and mathtext using pyplot
==============================

"""
import numpy as np
import matplotlib.pyplot as plt
Set the special text objects `~.pyplot.title`, `~.pyplot.xlabel`, and
`~.pyplot.ylabel` through the dedicated pyplot functions. Additional text
objects can be placed in the axes using `~.pyplot.text`.

# Fixing random state for reproducibility
np.random.seed(19680801)
You can use TeX-like mathematical typesetting in all texts; see also
:doc:`/tutorials/text/mathtext`.

mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
.. redirect-from:: /gallery/pyplots/pyplot_mathtext
"""

# the histogram of the data
n, bins, patches = plt.hist(x, 50, density=True, facecolor='g', alpha=0.75)
import numpy as np
import matplotlib.pyplot as plt

t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)

plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
plt.xlim(40, 160)
plt.ylim(0, 0.03)
plt.grid(True)
plt.plot(t, s)
plt.text(0, -1, r'Hello, world!', fontsize=15)
plt.title(r'$\mathcal{A}\sin(\omega t)$', fontsize=20)
plt.xlabel('Time [s]')
plt.ylabel('Voltage [mV]')
plt.show()

#############################################################################
Expand Down
9 changes: 5 additions & 4 deletions examples/pyplots/pyplot_three.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""
============
Pyplot Three
============
===========================
Multiple lines using pyplot
===========================

Plot three line plots in a single call to `~matplotlib.pyplot.plot`.
Plot three datasets with a single call to `~matplotlib.pyplot.plot`.
"""

import numpy as np
import matplotlib.pyplot as plt

Expand Down
9 changes: 5 additions & 4 deletions examples/pyplots/pyplot_two_subplots.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""
===================
Pyplot Two Subplots
===================
=========================
Two subplots using pyplot
=========================

Create a figure with two subplots with `.pyplot.subplot`.
Create a figure with two subplots using `.pyplot.subplot`.
"""

import numpy as np
import matplotlib.pyplot as plt

Expand Down
4 changes: 2 additions & 2 deletions tutorials/text/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
-------
Here is an example illustrating many of these features in context.

.. figure:: ../../gallery/pyplots/images/sphx_glr_pyplot_mathtext_001.png
:target: ../../gallery/pyplots/pyplot_mathtext.html
.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_mathtext_demo_001.png
:target: ../../gallery/text_labels_and_annotations/mathtext_demo.html
:align: center
"""