10000 tricontour and tricontourf hang · Issue #4437 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
tricontour and tricontourf hang #4437
Closed
@divenex

Description

@divenex

tricontour and tricontourf can hang and enter an infinite loop in special circumstances. I give below a minimal working example reproducing the problem with Python 3.4.2, Matplotlib 1.4.3 and Numpy 1.9.2. The problem seems to be due to nearly collinear points, in fact it disappear by randomly perturbing the (x, y) coordinates by a minimal amount. In the example below, the problem also disappear by simply changing the rotation angle theta from 25 to 30 degrees.

import matplotlib.pyplot as plt
import numpy as np

xi = np.linspace(-2, 2, 100)
x, y = map(np.ravel, np.meshgrid(xi, xi))
z = np.exp(-x**2 - y**2)

w = x > y - 1
x, y, z = x[w], y[w], z[w]

theta = np.radians(25)
x1 = x*np.cos(theta) - y*np.sin(theta)
y1 = x*np.sin(theta) + y*np.cos(theta)

plt.tricontour(x1, y1, z, 15, linewidths=0.5)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0