<h3 dir="auto">Bug report</h3>
<p dir="auto">I am trying to use np.polyfit function. I have been using this for quite some time, but yesterday realize that something is broken. First I use a polyfit to find a line arguments then I plot the graph, but when trying to call polyfit for the second time, it produce the error, even thou I am calling the same function with the same arguments.<br>
raise LinAlgError("SVD did not converge in Linear Least Squares")<br>
numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares</p>
<p dir="auto"><strong>Bug summary</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import matplotlib.pyplot as plt

import numpy.polynomial.polynomial as poly

x = np.linspace(0, 1e-5*10000, 10000, endpoint=False)
y = np.random.random(10000)
coef = poly.polyfit(x, y, 1)[::-1]
print(coef)

x_fit = np.zeros(2)
x_fit[:] = [x[0], x[-1]]
y_fit = x_fit*coef[0] + coef[1]

plt.plot(x, y, linewidth=0.1)
plt.plot(x_fit, y_fit, linewidth=2, linestyle='--', color='red')
plt.show()
plt.close(&quot;all&quot;)

coef = poly.polyfit(x[1:], y[1:], 1)[::-1]
print(coef)

#"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>

<span class="pl-k">import</span> <span class="pl-s1">numpy</span>.<span class="pl-s1">polynomial</span>.<span class="pl-s1">polynomial</span> <span class="pl-k">as</span> <span class="pl-s1">poly</span>

<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">0</span>, <span class="pl-c1">1e-5</span><span class="pl-c1">*</span><span class="pl-c1">10000</span>, <span class="pl-c1">10000</span>, <span class="pl-s1">endpoint</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
<span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">random</span>(<span class="pl-c1">10000</span>)
<span class="pl-s1">coef</span> <span class="pl-c1">=</span> <span class="pl-s1">poly</span>.<span class="pl-en">polyfit</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>, <span class="pl-c1">1</span>)[::<span class="pl-c1">-</span><span class="pl-c1">1</span>]
<span class="pl-en">print</span>(<span class="pl-s1">coef</span>)

<span class="pl-s1">x_fit</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">zeros</span>(<span class="pl-c1">2</span>)
<span class="pl-s1">x_fit</span>[:] <span class="pl-c1">=</span> [<span class="pl-s1">x</span>[<span class="pl-c1">0</span>], <span class="pl-s1">x</span>[<span class="pl-c1">-</span><span class="pl-c1">1</span>]]
<span class="pl-s1">y_fit</span> <span class="pl-c1">=</span> <span class="pl-s1">x_fit</span><span class="pl-c1">*</span><span class="pl-s1">coef</span>[<span class="pl-c1">0</span>] <span class="pl-c1">+</span> <span class="pl-s1">coef</span>[<span class="pl-c1">1</span>]

<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>, <span class="pl-s1">linewidth</span><span class="pl-c1">=</span><span class="pl-c1">0.1</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x_fit</span>, <span class="pl-s1">y_fit</span>, <span class="pl-s1">linewidth</span><span class="pl-c1">=</span><span class="pl-c1">2</span>, <span class="pl-s1">linestyle</span><span class="pl-c1">=</span><span class="pl-s">'--'</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s">'red'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">close</span>(<span class="pl-s">"all"</span>)

<span class="pl-s1">coef</span> <span class="pl-c1">=</span> <span class="pl-s1">poly</span>.<span class="pl-en">polyfit</span>(<span class="pl-s1">x</span>[<span class="pl-c1">1</span>:], <span class="pl-s1">y</span>[<span class="pl-c1">1</span>:], <span class="pl-c1">1</span>)[::<span class="pl-c1">-</span><span class="pl-c1">1</span>]
<span class="pl-en">print</span>(<span class="pl-s1">coef</span>)

<span class="pl-c">#</span></pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# If applicable, paste the console output here
[0.21593069 0.48646648]
 ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  5 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
Traceback (most recent call last):
  File &quot;polyfit_example.py&quot;, line 31, in &lt;module&gt;
    coef = poly.polyfit(x[1:], y[1:], 1)[::-1]
  File &quot;C:\python38\lib\site-packages\numpy\polynomial\polynomial.py&quot;, line 1350, in polyfit
    return pu._fit(polyvander, x, y, deg, rcond, full, w)
  File &quot;C:\python38\lib\site-packages\numpy\polynomial\polyutils.py&quot;, line 706, in _fit
    c, resids, rank, s = np.linalg.lstsq(lhs.T/scl, rhs.T, rcond)
  File &quot;&lt;__array_function__ internals&gt;&quot;, line 5, in lstsq
  File &quot;C:\python38\lib\site-packages\numpy\linalg\linalg.py&quot;, line 2306, in lstsq
    x, resids, rank, s = gufunc(a, b, rcond, signature=signature, extobj=extobj)
  File &quot;C:\python38\lib\site-packages\numpy\linalg\linalg.py&quot;, line 100, in _raise_linalgerror_lstsq
    raise LinAlgError(&quot;SVD did not converge in Linear Least Squares&quot;)
numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares#
#"><pre class="notranslate"><code class="notranslate"># If applicable, paste the console output here
[0.21593069 0.48646648]
 ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  5 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
Traceback (most recent call last):
  File "polyfit_example.py", line 31, in &lt;module&gt;
    coef = poly.polyfit(x[1:], y[1:], 1)[::-1]
  File "C:\python38\lib\site-packages\numpy\polynomial\polynomial.py", line 1350, in polyfit
    return pu._fit(polyvander, x, y, deg, rcond, full, w)
  File "C:\python38\lib\site-packages\numpy\polynomial\polyutils.py", line 706, in _fit
    c, resids, rank, s = np.linalg.lstsq(lhs.T/scl, rhs.T, rcond)
  File "&lt;__array_function__ internals&gt;", line 5, in lstsq
  File "C:\python38\lib\site-packages\numpy\linalg\linalg.py", line 2306, in lstsq
    x, resids, rank, s = gufunc(a, b, rcond, signature=signature, extobj=extobj)
  File "C:\python38\lib\site-packages\numpy\linalg\linalg.py", line 100, in _raise_linalgerror_lstsq
    raise LinAlgError("SVD did not converge in Linear Least Squares")
numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares#
#
</code></pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>


<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system:<br>
Win10 64bit<br>
python-3.8.5-amd64<br>
Matplotlib 3.3.2<br>
numpy-1.19.2</li>
</ul>


<p dir="auto">pip install numpy<br>
pip install matplotlib</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>

<p dir="auto">savgol_filter crashes with an error in the lstsq algorithm if executed after a plot with dashed/dotted/dashdotted line style.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>

<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
from scipy.signal import savgol_filter

ls='--'
# ls=''
y = range(100)
plt.plot(y,ls)
try:
  y_filt=savgol_filter(y,11,2)
except Exception as e:
  print(e)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">from</span> <span class="pl-s1">scipy</span>.<span class="pl-s1">signal</span> <span class="pl-k">import</span> <span class="pl-s1">savgol_filter</span>

<span class="pl-s1">ls</span><span class="pl-c1">=</span><span class="pl-s">'--'</span>
<span class="pl-c"># ls=''</span>
<span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-en">range</span>(<span class="pl-c1">100</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-s1">y</span>,<span class="pl-s1">ls</span>)
<span class="pl-k">try</span>:
  <span class="pl-s1">y_filt</span><span class="pl-c1">=</span><span class="pl-en">savgol_filter</span>(<span class="pl-s1">y</span>,<span class="pl-c1">11</span>,<span class="pl-c1">2</span>)
<span class="pl-k">except</span> <span class="pl-v">Exception</span> <span class="pl-k">as</span> <span class="pl-s1">e</span>:
  <span class="pl-en">print</span>(<span class="pl-s1">e</span>)</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
SVD did not converge in Linear Least Squares"><pre class="notranslate"><code class="notranslate"> ** On entry to DLASCLS parameter number  4 had an illegal value
 ** On entry to DLASCLS parameter number  4 had an illegal value
SVD did not converge in Linear Least Squares
</code></pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>


<p dir="auto">It worked until recently without a change in any of the python libraries. I had it running in a fixed environment and it stopped working probably after a windows update. Now I can't get it to work on any PC with any python version.</p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: Windows 10.0.19041</li>
<li>Matplotlib version: 3.1.1</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>): TkAgg</li>
<li>Python version: 3.7.4</li>
<li>Jupyter version (if applicable): NA</li>
<li>Other libraries: scipy v1.5.2</li>
</ul>


<p dir="auto">installed python from the installer and the libraries with pip</p>