# Programming Machine Learning: some plot files are throwing error

**URL:** <https://forum.devtalk.com/t/programming-machine-learning-some-plot-files-are-throwing-error/83609>\
**Category:** PragProg Customers\
**Tags:** question, book-programming-machine-learning\
**Created:** [19 November 2022 14:04 UTC](https://forum.devtalk.com/t/programming-machine-learning-some-plot-files-are-throwing-error/83609 "2022-11-19T14:04:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ggerico](https://forum.devtalk.com/user_avatar/forum.devtalk.com/ggerico/32/4592_2.png) [@ggerico](https://forum.devtalk.com/u/ggerico)\
**Post date:** [19 November 2022 14:04 UTC](https://forum.devtalk.com/t/programming-machine-learning-some-plot-files-are-throwing-error/83609/1 "2022-11-19T14:04:03Z")

</div>

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:**

```auto
$ 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'

```

```auto
$ 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 :**

```auto
$ 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˜

---

<div class="post-metadata">

**Author:** ![nusco](https://forum.devtalk.com/user_avatar/forum.devtalk.com/nusco/32/5449_2.png) [@nusco](https://forum.devtalk.com/u/nusco)\
**Post date:** [19 November 2022 20:25 UTC](https://forum.devtalk.com/t/programming-machine-learning-some-plot-files-are-throwing-error/83609/2 "2022-11-19T20:25:47Z")

</div>

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](http://www.progml.com/setup).

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

---

<div class="post-metadata">

**Author:** ![ggerico](https://forum.devtalk.com/user_avatar/forum.devtalk.com/ggerico/32/4592_2.png) [@ggerico](https://forum.devtalk.com/u/ggerico)\
**Post date:** [23 November 2022 01:27 UTC](https://forum.devtalk.com/t/programming-machine-learning-some-plot-files-are-throwing-error/83609/3 "2022-11-23T01:27:58Z")

</div>

I have used the instruction **Installing with Conda** from [progml.com/setup](http://www.progml.com/setup) using the macOS package. I followed the bash commands you mentioned there, they worked well, except for numpy where I had to go to [anaconda.org](https://anaconda.org/cctbx202105/numpy) and used `conda install -c cctbx202105 numpy ` instead.

Everything’s alright now, tks again!

---

<div class="post-metadata">

**Author:** ![nusco](https://forum.devtalk.com/user_avatar/forum.devtalk.com/nusco/32/5449_2.png) [@nusco](https://forum.devtalk.com/u/nusco)\
**Post date:** [23 November 2022 15:12 UTC](https://forum.devtalk.com/t/programming-machine-learning-some-plot-files-are-throwing-error/83609/4 "2022-11-23T15:12:14Z")

</div>

Thank you for the info! I’ll update the setup instructions ASAP.

---

<div class="post-metadata">

**Author:** ![fidus-Achates](https://forum.devtalk.com/user_avatar/forum.devtalk.com/fidus-achates/32/5358_2.png) [@fidus-Achates](https://forum.devtalk.com/u/fidus-Achates)\
**Post date:** [30 August 2023 00:24 UTC](https://forum.devtalk.com/t/programming-machine-learning-some-plot-files-are-throwing-error/83609/5 "2023-08-30T00:24:36Z")

</div>

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

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

```

instead of

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

```

it works.

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

---

<div class="post-metadata">

**Author:** ![nusco](https://forum.devtalk.com/user_avatar/forum.devtalk.com/nusco/32/5449_2.png) [@nusco](https://forum.devtalk.com/u/nusco)\
**Post date:** [17 September 2023 09:42 UTC](https://forum.devtalk.com/t/programming-machine-learning-some-plot-files-are-throwing-error/83609/6 "2023-09-17T09:42:29Z")

</div>

Claudia, thank you for reporting this issue, and sorry that I took so long to reply! At this stage, it’s becoming hard for me to update the instructions for the book. I’ll add a note to the instructions on [progml.com](http://progml.com), and leave the fix for the next edition.
