Skip to content

Usetex demo is slow on windows #15802

@Echeban

Description

@Echeban

Bug report

Bug summary

I just downloaded usetex_demo.html
from
https://matplotlib.org/3.1.1/gallery/text_labels_and_annotations/usetex_demo.html

I did not modify it, nothing at all. I just try to run it.

Code for reproduction

exactly what I downloaded.

Actual outcome

The canvas/figure appears on a window as usual when invoking plt.show() but it has no content and it is unresponsive. I have to kill it, which reports the problem to Microsoft.

Expected outcome

A figure similar to that shown on the documentation.

Matplotlib version

  • Operating system: Windows 10, 64
  • Matplotlib version:
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.7
  • Jupyter version (if applicable): N/A
  • Other libraries: numpy #as included in the demo. I load the code into VSCode, then hit F5. My VSCode installation is working fine. Everything runs inside a venv. Typical setup. All packages updated using pip. I installed everything from pip
    pip freeze:
    altgraph==0.16.1
    astroid==2.3.2
    cffi==1.13.2
    colorama==0.4.1
    cryptography==2.8
    cx-Freeze==6.0
    cycler==0.10.0
    future==0.18.2
    isort==4.3.21
    kiwisolver==1.1.0
    lazy-object-proxy==1.4.3
    matplotlib==3.1.1
    mccabe==0.6.1
    numpy==1.17.3
    pefile==2019.4.18
    plint==0.1
    pycparser==2.19
    pylint==2.4.3
    pyparsing==2.4.2
    PyQt5==5.13.2
    PyQt5-sip==12.7.0
    python-dateutil==2.8.1
    pywin32-ctypes==0.2.0
    scipy==1.3.1
    six==1.12.0
    typed-ast==1.4.0
    wrapt==1.11.2

"""

Usetex Demo

Shows how to use latex in a plot.

Also, refer to the :doc:/tutorials/text/usetex guide.
This code from: https://matplotlib.org/3.1.1/gallery/text_labels_and_annotations/usetex_demo.html


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

# interface tracking profiles
N = 500
delta = 0.6
X = np.linspace(-1, 1, N)
plt.plot(X, (1 - np.tanh(4 * X / delta)) / 2,    # phase field tanh profiles
         X, (1.4 + np.tanh(4 * X / delta)) / 4, "C2",  # composition profile
         X, X < 0, 'k--')                        # sharp interface

# legend
plt.legend(('phase field', 'level set', 'sharp interface'),
           shadow=True, loc=(0.01, 0.48), handlelength=1.5, fontsize=16)

# the arrow
plt.annotate("", xy=(-delta / 2., 0.1), xytext=(delta / 2., 0.1),
             arrowprops=dict(arrowstyle="<->", connectionstyle="arc3"))
plt.text(0, 0.1, r'$\delta$',
         {'color': 'black', 'fontsize': 24, 'ha': 'center', 'va': 'center',
          'bbox': dict(boxstyle="round", fc="white", ec="black", pad=0.2)})

# Use tex in labels
plt.xticks((-1, 0, 1), ('$-1$', r'$\pm 0$', '$+1$'), color='k', size=20)

# Left Y-axis labels, combine math mode and text mode
plt.ylabel(r'\bf{phase field} $\phi$', {'color': 'C0', 'fontsize': 20})
plt.yticks((0, 0.5, 1), (r'\bf{0}', r'\bf{.5}', r'\bf{1}'), color='k', size=20)

# Right Y-axis labels
plt.text(1.02, 0.5, r"\bf{level set} $\phi$", {'color': 'C2', 'fontsize': 20},
         horizontalalignment='left',
         verticalalignment='center',
         rotation=90,
         clip_on=False,
         transform=plt.gca().transAxes)

# Use multiline environment inside a `text`.
# level set equations
eq1 = r"\begin{eqnarray*}" + \
      r"|\nabla\phi| &=& 1,\\" + \
      r"\frac{\partial \phi}{\partial t} + U|\nabla \phi| &=& 0 " + \
      r"\end{eqnarray*}"
plt.text(1, 0.9, eq1, {'color': 'C2', 'fontsize': 18}, va="top", ha="right")

# phase field equations
eq2 = r'\begin{eqnarray*}' + \
      r'\mathcal{F} &=& \int f\left( \phi, c \right) dV, \\ ' + \
      r'\frac{ \partial \phi } { \partial t } &=& -M_{ \phi } ' + \
      r'\frac{ \delta \mathcal{F} } { \delta \phi }' + \
      r'\end{eqnarray*}'
plt.text(0.18, 0.18, eq2, {'color': 'C0', 'fontsize': 16})

plt.text(-1, .30, r'gamma: $\gamma$', {'color': 'r', 'fontsize': 20})
plt.text(-1, .18, r'Omega: $\Omega$', {'color': 'b', 'fontsize': 20})

plt.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy