Skip to content

remove backend matplotlib.use('nbagg') and add ipympl #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 74 additions & 24 deletions AnatomyOfMatplotlib-Part0-Intro2NumPy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -24,7 +27,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -43,7 +49,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -57,7 +66,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -71,7 +83,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -93,7 +108,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -112,7 +130,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -131,7 +152,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -143,7 +167,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -155,7 +182,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -170,7 +200,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -182,7 +215,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -201,9 +237,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"print(\"Shape of X:\", x.shape)\n",
Expand All @@ -221,7 +255,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -246,7 +283,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -261,7 +301,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
Expand All @@ -271,27 +314,34 @@
"z = x * y\n",
"print(z.shape)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 4
}
36 changes: 15 additions & 21 deletions AnatomyOfMatplotlib-Part1-Figures_Subplots_and_layouts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"slideshow": {
"slide_type": "-"
}
Expand Down Expand Up @@ -78,6 +81,7 @@
"metadata": {},
"outputs": [],
"source": [
"%matplotlib widget\n",
"import matplotlib\n",
"print(matplotlib.__version__)\n",
"print(matplotlib.get_backend())"
Expand All @@ -87,33 +91,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If you are working interactively at an (I)python prompt, the GUI framework is not critical (mostly aesthetic) however when working in Jupyter we need to pick a backend that integrates with Jupyter (javascript) framework.\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still useful content for people who will are reading this that will mostly work at a prompt. Can it just be re-worrked rather than fully deleted?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added that part back. Hope that's fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this alright, or needs rephrasing?

"\n",
"To select the backend use ``matplotlib.use(\"backend_name\")``, in this case we want ``'nbagg'``\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"matplotlib.use('nbagg')\n",
"print(matplotlib.get_backend())"
"If you are working interactively at an (I)python prompt, the GUI framework is not critical (mostly aesthetic) however when working in Jupyter we need to pick a backend that integrates with Jupyter (javascript) framework."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"which must be done *before* you `import matplotlib.pyplot as plt`.\n",
"\n",
"You can also set the backend via an 'ipython magic' ``%matplotlib backend_name``. In addition to setting the backend, the magic also calls `plt.ion()`, which puts Matplotlib in 'interacitve mode' (the inverse is `plt.ioff()`). In 'interactive mode' figures are shown (injected into the web page in the notebook) as soon as they are created. Otherwise, figures are not shown until you explicitly call `plt.show()`.\n",
"\n",
"\n",
"In these tutorials we will mostly work in non-interactive mode for better control of when\n",
"figures are shown in the notebooks.\n",
"This also better mimics the behavior you can expect in regular python scripts.\n"
"This also better mimics the behavior you can expect in regular python scripts."
]
},
{
Expand Down Expand Up @@ -457,6 +444,13 @@
"\n",
"# Can you figure out what to do next to plot x vs y1, y2, and y3 on one figure?\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -475,9 +469,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
6 changes: 3 additions & 3 deletions AnatomyOfMatplotlib-Part2-Plotting_Methods_Overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"# Let's get our standard imports out of the way\n",
"from __future__ import print_function\n",
"import numpy as np\n",
"%matplotlib widget\n",
"import matplotlib\n",
"matplotlib.use('nbagg')\n",
"import matplotlib.pyplot as plt"
]
},
Expand Down Expand Up @@ -462,9 +462,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
8 changes: 4 additions & 4 deletions AnatomyOfMatplotlib-Part3-HowToSpeakMPL.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"# Let printing work the same in Python 2 and 3\n",
"from __future__ import print_function\n",
"# Turning on notebook plots -- just for use in jupyter notebooks.\n",
"%matplotlib widget\n",
"import matplotlib\n",
"matplotlib.use('nbagg')\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
Expand Down Expand Up @@ -81,7 +81,7 @@
"metadata": {},
"outputs": [],
"source": [
"%load exercises/3.1-colors.py\n"
"%load exercises/3.1-colors.py"
]
},
{
Expand Down Expand Up @@ -607,9 +607,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Loading