pyplot
Wrapper for matplotlib plotting functions.
imshow(*args, ax=None, **kwargs)
¶
Display an image, i.e. data on a 2D regular raster.
This is a wrapper of pyplot.imshow(). In contrast to the original function
the default value of zorder
is increased to 1
.
Parameters:
-
ax
(Axes
, default:None
) –matplotlib.axes.Axes to plot in.
-
args
– -
kwargs
–
Returns:
-
im
(AxesImage
) –Reference to plotted image matplotlib.image.AxesImage
Source code in src/prettypyplot/pyplot.py
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 |
|
plot(*args, ax=None, **kwargs)
¶
Plot simple lineplot.
Wrapping pyplot.plot() to adjust to style. For more information on the
arguments see in matplotlib documentation.
If STYLE='minimal'
, spines will be limited to plotting range.
Parameters:
-
ax
(Axes
, default:None
) –matplotlib.axes.Axes to plot in.
-
args
– -
kwargs
–
Returns:
-
lines
(list of Line2D
) –A list of matplotlib.lines.Line2D representing the plotted data.
Source code in src/prettypyplot/pyplot.py
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 |
|
savefig(fname, reference_ax=None, use_canvas_size=True, **kwargs)
¶
Save figure as png and pdf.
This methods corrects figsize for poster/beamer mode.
Parameters:
-
fname
(str
) –Output filename. If no file ending, pdf will be used.
-
reference_ax
(Axes
, default:None
) –matplotlib.axes.Axes used for resizing. If
None
first axes of figure is used. -
use_canvas_size
(bool
, default:True
) –If True the specified figsize will be used as canvas size.
-
kwargs
–
Source code in src/prettypyplot/pyplot.py
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 |
|
show(reference_ax=None, use_canvas_size=True, **kwargs)
¶
Show figure and rescale similar to pplt.savefig.
Parameters:
-
reference_ax
(Axes
, default:None
) –matplotlib.axes.Axes used for resizing. If
None
first axes of figure is used. -
use_canvas_size
(bool
, default:True
) –If True the specified figsize will be used as canvas size.
-
kwargs
–
Source code in src/prettypyplot/pyplot.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
legend(*args, outside=False, ax=None, axs=None, **kwargs)
¶
Generate a nice legend.
This is a wrapper of pyplot.legend(). Take a look there for the default
arguments and options. The ticks and labels are moved to the opposite side.
For top
and bottom
the default value of columns is set to the number of
labels, for all other options to 1. In case of many labels this parameter
needs to be adjusted.
Note
Use handles and labels from *args if provided
Example
Checkout the gallery for an example.
Parameters:
-
outside
(str or bool
, default:False
) –False, 'top', 'right', 'bottom' or 'left'.
-
axs
(list of Axes
, default:None
) –List of matplotlib.axes.Axes which are used for extracting all labels.
-
ax
(Axes
, default:None
) –matplotlib.axes.Axes which is used for placing legend.
-
args
– -
kwargs
–
Returns:
-
leg
(Legend
) –[matplotlib.legend.Legend] legend handle.
Source code in src/prettypyplot/pyplot.py
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 |
|
activate_axis(position, ax=None)
¶
Shift the specified axis to the opposite side.
Parameters:
-
position
(str or list of str
) –Specify axis to flip, one of
['left', 'right', 'top', 'bottom']
. -
ax
(Axes
, default:None
) –matplotlib.axes.Axes axes to flip axis.
Source code in src/prettypyplot/pyplot.py
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 |
|
colorbar(im, width='7%', pad='0%', position='right', label=None, **kwargs)
¶
Generate colorbar of same height as image.
Wrapper around pyplot.colorbar which corrects the height.
Example
Checkout the gallery for an example.
Parameters:
-
im
(AxesImage
) –Specify the object the colorbar belongs to, e.g. the return value of matplotlib.pyplot.imshow.
-
width
(str or float
, default:'7%'
) –The width between figure and colorbar stated relative as string ending with '%' or absolute value in inches.
-
pad
(str or float
, default:'0%'
) –The width between figure and colorbar stated relative as string ending with '%' or absolute value in inches.
-
position
(str
, default:'right'
) –Specify the position relative to the image where the colorbar is plotted, choose one of ['left', 'top', 'right', 'bottom']
-
label
(str
, default:None
) –Specify the colorbar label.
-
kwargs
–Colorbar properties of, matplotlib.pyplot.colorbar.
Returns:
-
colorbar
(Colorbar
) –matplotlib.colorbar.Colorbar instance.
Source code in src/prettypyplot/pyplot.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
|
grid(*args, ax=None, **kwargs)
¶
Generate grid.
This function will add a major and minor grid in case of STYLE='default', a major grid in case of 'none' and otherwise nothing.
Parameters:
-
ax
(Axes
, default:None
) –[matplotlib.axes.Axes] axes to plot grid.
-
args
– -
kwargs
–
Source code in src/prettypyplot/pyplot.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
|