Bug report
Bug summary
When using contour plots with the PGF backend, contour labels close to the axes can protrude beyond the axis boundary. This was originally posted as a question at StackOverflow.
Code for reproduction
(See the contour_demo.py example.)
import matplotlib
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'
delta = 0.025
x = np.arange(-3.0, 3.0, delta)
y = np.arange(-2.0, 2.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
# difference of Gaussians
Z = 10.0 * (Z2 - Z1)
# Create a simple contour plot with labels using default colors. The
# inline argument to clabel will control whether the labels are draw
# over the line segments of the contour, removing the lines beneath
# the label
plt.figure()
CS = plt.contour(X, Y, Z)
plt.clabel(CS, inline=1, fontsize=10)
plt.title('Simplest default with labels')
plt.savefig('plot.pgf')
Actual outcome

Expected outcome
The contour label at the top should be clipped, just as in the first image shown in the contour_demo.py example.
Matplotlib version
- Operating system: Ubuntu 17.10
- Matplotlib version: 2.2.2
- Matplotlib backend: PGF (
matplotlib.get_backend() shows TkAgg, though)
- Python version: 3.6.3
matplotlib was installed through pip.
Bug report
Bug summary
When using contour plots with the PGF backend, contour labels close to the axes can protrude beyond the axis boundary. This was originally posted as a question at StackOverflow.
Code for reproduction
(See the
contour_demo.pyexample.)Actual outcome
Expected outcome
The contour label at the top should be clipped, just as in the first image shown in the
contour_demo.pyexample.Matplotlib version
matplotlib.get_backend()showsTkAgg, though)matplotlibwas installed throughpip.