/usr/lib/python2.7/dist-packages/matplotlib/backends/web_backend/nbagg_uat.ipynb is in python-matplotlib 1.4.2-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | {
"metadata": {
"name": "",
"signature": "sha256:1d491e506b54b126f6971897d3249a9e6f96f9d50bf4e4ba8d179c6b7b1aefa8"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## UAT for NbAgg backend.\n",
"\n",
"The first line simply reloads matplotlib, uses the nbagg backend and then reloads the backend, just to ensure we have the latest modification to the backend code. Note: The underlying JavaScript will not be updated by this process, so a refresh of the browser after clearing the output and saving is necessary to clear everything fully."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import matplotlib\n",
"reload(matplotlib)\n",
"\n",
"matplotlib.use('nbagg')\n",
"\n",
"import matplotlib.backends.backend_nbagg\n",
"reload(matplotlib.backends.backend_nbagg)"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 1 - Simple figure creation using pyplot\n",
"\n",
"Should produce a figure window which is interactive with the pan and zoom buttons. (Do not press the close button, but any others may be used)."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import matplotlib.backends.backend_webagg_core\n",
"reload(matplotlib.backends.backend_webagg_core)\n",
"\n",
"import matplotlib.pyplot as plt\n",
"plt.interactive(False)\n",
"\n",
"fig1 = plt.figure()\n",
"plt.plot(range(10))\n",
"\n",
"plt.show()"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 2 - Creation of another figure, without the need to do plt.figure.\n",
"\n",
"As above, a new figure should be created."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.plot([3, 2, 1])\n",
"plt.show()"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 3 - Connection info\n",
"\n",
"The printout should show that there are two figures which have active CommSockets, and no figures pending show."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print(matplotlib.backends.backend_nbagg.connection_info())"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 4 - Closing figures\n",
"\n",
"Closing a specific figure instance should turn the figure into a plain image - the UI should have been removed. In this case, scroll back to the first figure and assert this is the case."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.close(fig1)"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 5 - No show without plt.show in non-interactive mode\n",
"\n",
"Simply doing a plt.plot should not show a new figure, nor indeed update an existing one (easily verified in UAT 6).\n",
"The output should simply be a list of Line2D instances."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.plot(range(10))"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 6 - Connection information\n",
"\n",
"We just created a new figure, but didn't show it. Connection info should no longer have \"Figure 1\" (as we closed it in UAT 4) and should have figure 2 and 3, with Figure 3 without any connections. There should be 1 figure pending."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print matplotlib.backends.backend_nbagg.connection_info()"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 7 - Show of previously created figure\n",
"\n",
"We should be able to show a figure we've previously created. The following should produce two figure windows."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.show()\n",
"plt.figure()\n",
"plt.plot(range(5))\n",
"plt.show()"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 8 - Interactive mode\n",
"\n",
"In interactive mode, creating a line should result in a figure being shown."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.interactive(True)\n",
"plt.figure()\n",
"plt.plot([3, 2, 1])"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Subsequent lines should be added to the existing figure, rather than creating a new one."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.plot(range(3))"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Disable interactive mode again."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.interactive(False)"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 9 - Multiple shows\n",
"\n",
"Unlike most of the other matplotlib backends, we may want to see a figure multiple times (with or without synchronisation between the views, though the former is not yet implemented). Assert that plt.gcf().canvas.manager.reshow() results in another figure window which is synchronised upon pan & zoom."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.gcf().canvas.manager.reshow()"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 10 - Saving notebook\n",
"\n",
"Saving the notebook (with CTRL+S or File->Save) should result in the saved notebook having static versions of the figues embedded within. The image should be the last update from user interaction and interactive plotting. (check by converting with ``ipython nbconvert <notebook>``)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 11 - Creation of a new figure on second show\n",
"\n",
"Create a figure, show it, then create a new axes and show it. The result should be a new figure.\n",
"\n",
"**BUG: Sometimes this doesn't work - not sure why (@pelson).**"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"fig = plt.figure()\n",
"plt.axes()\n",
"plt.show()\n",
"\n",
"plt.plot([1, 2, 3])\n",
"plt.show()"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 12 - OO interface\n",
"\n",
"Should produce a new figure and plot it."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from matplotlib.backends.backend_nbagg import new_figure_manager,show\n",
"\n",
"manager = new_figure_manager(1000)\n",
"fig = manager.canvas.figure\n",
"ax = fig.add_subplot(1,1,1)\n",
"ax.plot([1,2,3])\n",
"fig.show()"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## UAT 13 - Animation\n",
"\n",
"The following should generate an animated line:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import matplotlib.animation as animation\n",
"import numpy as np\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"x = np.arange(0, 2*np.pi, 0.01) # x-array\n",
"line, = ax.plot(x, np.sin(x))\n",
"\n",
"def animate(i):\n",
" line.set_ydata(np.sin(x+i/10.0)) # update the data\n",
" return line,\n",
"\n",
"#Init only required for blitting to give a clean slate.\n",
"def init():\n",
" line.set_ydata(np.ma.array(x, mask=True))\n",
" return line,\n",
"\n",
"ani = animation.FuncAnimation(fig, animate, np.arange(1, 200), init_func=init,\n",
" interval=32., blit=True)\n",
"plt.show()"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UAT 14 - Keyboard shortcuts in IPython after close of figure\n",
"\n",
"After closing the previous figure (with the close button above the figure) the IPython keyboard shortcuts should still function.\n",
"\n",
"### UAT 15 - Figure face colours\n",
"\n",
"The nbagg honours all colours appart from that of the figure.patch. The two plots below should produce a figure with a transparent background and a red background respectively (check the transparency by closing the figure, and dragging the resulting image over other content). There should be no yellow figure."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import matplotlib\n",
"matplotlib.rcParams.update({'figure.facecolor': 'red',\n",
" 'savefig.facecolor': 'yellow'})\n",
"plt.figure()\n",
"plt.plot([3, 2, 1])\n",
"\n",
"with matplotlib.rc_context({'nbagg.transparent': False}):\n",
" plt.figure()\n",
"\n",
"plt.plot([3, 2, 1])\n",
"plt.show()"
],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
|