Discussion:
Old matplotlib animation now fails
(too old to reply)
Martin Schöön
2024-10-15 20:16:41 UTC
Permalink
Some years ago I created a Python program that reads GPS data and
creates an animation stored in an mp4 file. Not very elegant but it
worked. Not very original as it was based on the example found here:

https://shorturl.at/dTCZZ

Last time it worked was about a year ago. Since then I have moved to a
later version of Debian and Conda and as a consequence a later version
of Python 3 (now 3.12.2).

Now my code fails. I have downloaded the latest version of the example
and it also fails.

It is the second to last line that throws an error:

l.set_data(x0, y0)

The error messages drills down to something called
"/home/.../matplotlib/lines.py", line 1289, in set_xdata

and tells me 'x must be a sequence'

I have started to dig around in matplotlib's documentation but my
strategy is clearly wanting. I don't really know where to start
looking for information on how to correct my code. Hence, this
call for help.

Any ideas?

TIA

/Martin
Stefan Ram
2024-10-15 20:29:32 UTC
Permalink
Post by Martin Schöön
l.set_data(x0, y0)
Well, I got to say, it's pretty rad that you're rocking Python!
That language is the bee's knees, for real.

As for your question, here's my two cents off the cuff:
Could it be that the newer Matplotlib versions are jonesing
for something like "l.set_data( [ x0 ],[ y0 ])" in that spot?
Martin Schöön
2024-10-16 08:20:10 UTC
Permalink
Post by Stefan Ram
Post by Martin Schöön
l.set_data(x0, y0)
Well, I got to say, it's pretty rad that you're rocking Python!
That language is the bee's knees, for real.
Could it be that the newer Matplotlib versions are jonesing
for something like "l.set_data( [ x0 ],[ y0 ])" in that spot?
Thanks, that was quick and adding square brackets fixed my code.

Me rocking Python?

/Martin
Stefan Ram
2024-10-16 10:51:18 UTC
Permalink
Post by Martin Schöön
Me rocking Python?
|to rock
|1. To use. To make do with, usually to great effect.
|"You don't need to make up the guest bed; we can rock the couch."
Urban Dictionary (2005) - Aaron Peckham (editor) (1979-04-03/),
Andrews McMeel Publishing, Kansas City
Martin Schöön
2024-10-16 15:52:55 UTC
Permalink
Post by Stefan Ram
Post by Martin Schöön
Me rocking Python?
|to rock
|1. To use. To make do with, usually to great effect.
|"You don't need to make up the guest bed; we can rock the couch."
Urban Dictionary (2005) - Aaron Peckham (editor) (1979-04-03/),
Andrews McMeel Publishing, Kansas City
That is a use and meaning of rock I was not aware of.

An example of what I use this Python code for (track top right):
https://shorturl.at/m3ZKp
(Youtube's compression algorithm clearly did not like this video.)

/Martin
rbowman
2024-10-16 21:47:08 UTC
Permalink
Post by Martin Schöön
Post by Stefan Ram
Post by Martin Schöön
l.set_data(x0, y0)
Well, I got to say, it's pretty rad that you're rocking Python!
That language is the bee's knees, for real.
Could it be that the newer Matplotlib versions are jonesing for
something like "l.set_data( [ x0 ],[ y0 ])" in that spot?
Thanks, that was quick and adding square brackets fixed my code.
Me rocking Python?
/Martin
You have to understand Stefan tries to use American slang, not always
entirely accurately. I think 'bee's knees' died out around 1931.
Chris Townley
2024-10-16 22:30:42 UTC
Permalink
Post by rbowman
Post by Martin Schöön
Post by Stefan Ram
Post by Martin Schöön
l.set_data(x0, y0)
Well, I got to say, it's pretty rad that you're rocking Python!
That language is the bee's knees, for real.
Could it be that the newer Matplotlib versions are jonesing for
something like "l.set_data( [ x0 ],[ y0 ])" in that spot?
Thanks, that was quick and adding square brackets fixed my code.
Me rocking Python?
/Martin
You have to understand Stefan tries to use American slang, not always
entirely accurately. I think 'bee's knees' died out around 1931.
Not sure about America, but the bee's knees is still in common use in the UK
--
Chris
rbowman
2024-10-17 03:19:17 UTC
Permalink
Post by Chris Townley
Not sure about America, but the bee's knees is still in common use in the UK
https://en.wikipedia.org/wiki/Bee's_knees

That version? A local bakery makes a honey flavored pastry they call
'bee's knees' but using it in a conversation would be campy.
Lawrence D'Oliveiro
2024-10-17 05:48:42 UTC
Permalink
Post by rbowman
A local bakery makes a honey flavored pastry they call
'bee's knees' but using it in a conversation would be campy.
What words zey choose to use eez nahn of your bee’s knees.
Lawrence D'Oliveiro
2024-10-16 22:48:59 UTC
Permalink
Post by rbowman
I think 'bee's knees' died out around 1931.
Cat’s meow. Dog’s bollocks.

Speaking of the cat’s meow, did William Randolph Hearst really intend to
kill Charlie Chaplin?

<https://www.imdb.com/title/tt0266391/>
Stefan Ram
2024-10-17 13:50:13 UTC
Permalink
Post by rbowman
You have to understand Stefan tries to use American slang, not always
entirely accurately. I think 'bee's knees' died out around 1931.
There's some wild connections between Python and slang.
In the streets, folks might drop a "That's bonkers as f!",
and wouldn't ya know it, Python's rockin' the same vibe:

with open( "data", "rb" )as f:

. I'd wager that when you open a file "as f", it's probably packing
more of a punch or running like a cheetah on Red Bull or something!
Lawrence D'Oliveiro
2024-10-15 22:48:14 UTC
Permalink
Post by Martin Schöön
l.set_data(x0, y0)
Near as I can tell, “l” contains a Line2D object, so the applicable
set_data call is here:

<https://matplotlib.org/stable/api/_as_gen/matplotlib.lines.Line2D.html#matplotlib.lines.Line2D.set_data>
MRAB
2024-10-15 23:38:01 UTC
Permalink
Post by Martin Schöön
Some years ago I created a Python program that reads GPS data and
creates an animation stored in an mp4 file. Not very elegant but it
https://shorturl.at/dTCZZ
Last time it worked was about a year ago. Since then I have moved to a
later version of Debian and Conda and as a consequence a later version
of Python 3 (now 3.12.2).
Now my code fails. I have downloaded the latest version of the example
and it also fails.
l.set_data(x0, y0)
The error messages drills down to something called
"/home/.../matplotlib/lines.py", line 1289, in set_xdata
and tells me 'x must be a sequence'
I have started to dig around in matplotlib's documentation but my
strategy is clearly wanting. I don't really know where to start
looking for information on how to correct my code. Hence, this
call for help.
Any ideas?
This is from the help:

"""
Help on function set_data in module matplotlib.lines:

set_data(self, *args)
Set the x and y data.

Parameters
----------
*args : (2, N) array or two 1D arrays

See Also
--------
set_xdata
set_ydata
"""

So, the arguments should be arrays:

For example:

x0, y0 = np.array([0.0]), np.array([0.0])

Has the API changed at some point?
Martin Schöön
2024-10-16 08:23:17 UTC
Permalink
Post by MRAB
Post by Martin Schöön
Some years ago I created a Python program that reads GPS data and
<snip>
Post by MRAB
Post by Martin Schöön
l.set_data(x0, y0)
The error messages drills down to something called
"/home/.../matplotlib/lines.py", line 1289, in set_xdata
and tells me 'x must be a sequence'
<snip>
Post by MRAB
"""
set_data(self, *args)
Set the x and y data.
Parameters
----------
*args : (2, N) array or two 1D arrays
See Also
--------
set_xdata
set_ydata
"""
x0, y0 = np.array([0.0]), np.array([0.0])
Has the API changed at some point?
So it seems.

Thanks for the quick reply.

/Martin
Loading...