Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Inconsistent behavior of backends when rendering latex colors #6724

Open
Labels
Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesDifficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!keepItems to be ignored by the “Stale” Github Actiontopic: text/usetex
@madphysicist

Description

@madphysicist

MPL 1.5.1 on Python 3.5 (Anaconda) running on Red Hat 6.5.

This issue is a followup to the discussion on matplotlib-usersCreating Colored Axis Labels using LaTeX in Interactive Mode, which in turn is a followup to Stack OverflowInconsistent rendering of hdashrule in matplotlib axis labels.

In my attempts to get latex colors to show up correctly in axis labels using interactive backends with LaTeX enabled, I came acrosshttp://matplotlib.org/users/pgf.html. I expected to be able to do the following:

import matplotlib as mplfrom matplotlib.backends.backend_pgf import FigureCanvasPgfmatplotlib.backend_bases.register_backend('png', FigureCanvasPgf)from matplotlib import pyplot as pltmatplotlib.rc('pgf', texsystem='pdflatex')  # from running latex -vpreamble = matplotlib.rcParams.setdefault('pgf.preamble', [])preamble.append(r'\usepackage{color}')preamble.append(r'\usepackage{dashrule}')ax = plt.plot((0, 1), (1, 2))[0].axesax.set_ylabel(r'Y $\;$ \textcolor[rgb]{1.0, 0.0, 0.0}{\hdashrule[0.5ex]{3cm}{1pt}{1pt 0pt}}')ax.set_xlabel(r'N $\;$ \textcolor[rgb]{0.0, 1.0, 0.0}{\rule[0.5ex]{3cm}{1pt}}')plt.savefig('test.png')

With the default backend, this does not work at all, and the labels are rendered as raw strings containing TeX commands. Withmpl.use('pgf'), the lines in the labels are rendered black instead of the intended color. Please see the SO question and mailing list discussion for more info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesDifficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!keepItems to be ignored by the “Stale” Github Actiontopic: text/usetex

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp