ggerico

ggerico

Programming Machine Learning: some plot files are throwing error

I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1:

programming_ML/code/03_gradient:

$ python3 plot_loss_with_path.py
Traceback (most recent call last):
  File "/Users/germain/Code/lang/python/programming_ML/code/03_gradient/plot_loss_with_path.py", line 70, in <module>
    ax = plt.figure().gca(projection="3d")
TypeError: FigureBase.gca() got an unexpected keyword argument 'projection'
$ python3 plot_loss_with_slices.py
Traceback (most recent call last):
  File "/Users/germain/Code/lang/python/programming_ML/code/03_gradient/plot_loss_with_slices.py", line 70, in <module>
    ax = plt.figure().gca(projection="3d")
TypeError: FigureBase.gca() got an unexpected keyword argument 'projection'

programming_ML/code/04_hyperspace :

$ python3 plot_plane.py
Traceback (most recent call last):
  File "/Users/germain/Code/lang/python/programming_ML/code/04_hyperspace/plot_plane.py", line 17, in <module>
    ax = plt.figure().gca(projection="3d")
TypeError: FigureBase.gca() got an unexpected keyword argument 'projection'

There is a fix ?
tks˜

Marked As Solved

nusco

nusco

Author of Metaprogramming Ruby & Programming Machine Learning

Hey, @ggerico. Did you follow the instructions to set up the right libraries? The ones in the book are potentially outdated, so I recommend these ones.

If you still have the problem after following the instructions on progml.com, then it’s something that I should look into. In that case, could you please let me know?

Also Liked

fidus-Achates

fidus-Achates

I had the same problem using matplotlib 3. 7. 2.
with

fig = plt.figure()
ax = fig.add_subplot(projection="3d")

instead of

ax = plt.figure().gca(projection="3d")

it works.

Thanks for all the additional code and explanations completing this excellent book!
Claudia

Popular Pragmatic Bookshelf topics Top

New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
raul
Hi Travis! Thank you for the cool book! :slight_smile: I made a list of issues and thought I could post them chapter by chapter. I’m rev...
New
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |&gt; handle_event() |&gt; render() but the correc...
New
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
New
adamwoolhether
When trying to generate the protobuf .go file, I receive this error: Unknown flag: --go_opt libprotoc 3.12.3 MacOS 11.3.1 Googling ...
New
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
axelson
I’ve been really enjoying obsidian.md: It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New
AstonJ
Or looking forward to? :nerd_face:
New
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1132 25355 750
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New