【问题标题】:matplotlib PGF output: Contour labels extend beyond figure boundarymatplotlib PGF 输出:轮廓标签超出图形边界
【发布时间】:2018-05-27 17:41:01
【问题描述】:

matplotlib examples page中的第一个例子,

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')

我遇到的问题是靠近轴的轮廓标签(这里是最顶部的“0.000”)超出图形边界。这是我使用 LaTeX 得到的输出: 如您所见,顶部的标签“0.000”与黑线重叠。

我能做些什么来解决这个问题吗?需要明确的是,我的问题是 not 标签靠近轴。我想要的是与matplotlib page 上显示的相同的行为,即绘图内容被剪切到图形区域,切断文本和线条。

【问题讨论】:

    标签: python matplotlib pgf


    【解决方案1】:

    corresponding bug report for matplotlib (#11375) 所示,matplotlib 的 PGF 后端不支持文本剪辑,这导致了这个问题,今天似乎仍然存在。

    【讨论】:

      猜你喜欢
      • 2020-12-14
      • 1970-01-01
      • 2016-01-12
      • 1970-01-01
      • 2019-05-08
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多