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

Skip to content

Use rc() less often in examples/tutorials. #16578

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 1 commit into from
Feb 27, 2020
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
6 changes: 3 additions & 3 deletions examples/misc/multipage_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
pdf.savefig() # saves the current figure into a pdf page
plt.close()

# if LaTeX is not installed or error caught, change to `usetex=False`
plt.rc('text', usetex=True)
# if LaTeX is not installed or error caught, change to `False`
plt.rcParams['text.usetex'] = True
plt.figure(figsize=(8, 6))
x = np.arange(0, 5, 0.1)
plt.plot(x, np.sin(x), 'b-')
Expand All @@ -36,7 +36,7 @@
pdf.savefig()
plt.close()

plt.rc('text', usetex=False)
plt.rcParams['text.usetex'] = False
fig = plt.figure(figsize=(4, 5))
plt.plot(x, x ** 2, 'ko')
plt.title('Page Three')
Expand Down
2 changes: 0 additions & 2 deletions examples/text_labels_and_annotations/mathtext_asarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import matplotlib.mathtext as mathtext
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rc('image', origin='upper')

parser = mathtext.MathTextParser("Bitmap")
parser.to_png('test2.png',
Expand Down
4 changes: 1 addition & 3 deletions examples/text_labels_and_annotations/usetex_fonteffects.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
are now supported in pdf usetex.
"""

import matplotlib
import matplotlib.pyplot as plt
matplotlib.rc('text', usetex=True)


def setfont(font):
Expand All @@ -22,7 +20,7 @@ def setfont(font):
['Nimbus Roman No9 L ' + x for x in
['', 'Italics (real italics for comparison)',
'(slanted)', '(condensed)', '(extended)']]):
plt.text(0, y, setfont(font) + text)
plt.text(0, y, setfont(font) + text, usetex=True)

plt.ylim(-1, 5)
plt.xlim(-0.2, 0.6)
Expand Down
6 changes: 1 addition & 5 deletions examples/user_interfaces/embedding_in_wx3_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
Thanks to matplotlib and wx teams for creating such great software!
"""

import matplotlib
import matplotlib.cm as cm
import matplotlib.cbook as cbook
from matplotlib.backends.backend_wxagg import (
Expand All @@ -36,9 +35,6 @@
ERR_TOL = 1e-5 # floating point slop for peak-detection


matplotlib.rc('image', origin='lower')


class PlotPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
Expand All @@ -64,7 +60,7 @@ def init_plot_data(self):
y = np.arange(100.0) * 2 * np.pi / 50.0
self.x, self.y = np.meshgrid(x, y)
z = np.sin(self.x) + np.cos(self.y)
self.im = ax.imshow(z, cmap=cm.RdBu)
self.im = ax.imshow(z, cmap=cm.RdBu, origin='lower')

zmax = np.max(z) - ERR_TOL
ymax_i, xmax_i = np.nonzero(z >= zmax)
Expand Down
14 changes: 10 additions & 4 deletions tutorials/text/usetex.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@
To use LaTeX and select Helvetica as the default font, without editing
matplotlibrc use::

from matplotlib import rc
rc('font', **{'family': 'sans-serif', 'sans-serif': ['Helvetica']})
import matplotlib as mpl
plt.rcParams.update({
"text.usetex": True,
"font.family": "sans-serif",
"font.sans-serif": ["Helvetica"]})
## for Palatino and other serif fonts use:
# rc('font', **{'family': 'serif', 'serif': ['Palatino']})
rc('text', usetex=True)
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.serif": ["Palatino"],
})

Here is the standard example,
:file:`/gallery/text_labels_and_annotations/tex_demo`:
Expand Down