[Matplotlib-users] Possible regression in plotting lists of strings after 2.0
tcaswell at gmail.com
Sat Oct 27 12:59:49 EDT 2018
This is an intentional change to support categorical string-data (see
Plotting a list of strings that happened to be floats worked <2.1 by chance
because there was a `np.asarray(data)` someplace which worked because numpy
implicitly did the conversion. You are not the only person to hit this,
we miss-estimated how used this accidental feature was, sorry.
The most reliable path is to convert your data to numeric types before
handing it to Matplotlib (this will be guaranteed to work on all past and
future versions of Matplotlib!).
On Thu, Oct 25, 2018 at 1:08 AM Douglas Clowes <douglas.clowes at gmail.com>
> On Thu, Oct 25, 2018 at 2:19 PM Douglas Clowes <douglas.clowes at gmail.com>
>> I had a program that seemed to work fine on Fedora 27 (matplotlib 2.0.0)
>> but exhibits strange behaviour on Fedora 29 (matplotlib 2.2.3) and Rawhide
>> (matplotlib 3.0.0). Behaviour is the same with either python 2 or 3.
>> The following "minimalist" program performs well where "y" is a list of
>> floats and on 2.0.0 with either floats or strings. On later versions with
>> * it plots a straight line
>> * has y-axis labels on every point
>> * has linear spacing of non-linear points on y-axis
>> * pressing "l" (lower-case L) yields a different scale and labels
>> With read data (not monotonic) it yields even stranger results.
>> Since it used to work, is it expected to work with strings or did I just
>> get lucky?
>> #!/usr/bin/env python3
>> import csv
>> import sys
>> import matplotlib.pyplot as plt
>> x = range(11)
>> if "-s" in sys.argv:
>> y = [str(i*i) for i in x]
>> y = [i*i for i in x]
>> plt.plot(x, y, "+-")
> Matplotlib-users mailing list
> Matplotlib-users at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users