color_cycle
Styling with cyclerDemo of custom property-cycle settings to control colors and other styleproperties for multi-line plots. ::: tip Note More complete documentation of the cycler API can be foundhere. ::: This example demonstrates two different APIs: Setting the default rc parameter specifying the property cycle.This affects all subsequent axes (but not axes already created). Setting the property cycle for a single pair of axes. 123from cycler import cyclerimport numpy as npimport matplotli...
imshow_extent
origin and extent in imshowimshow() allows you to render an image (either a 2D arraywhich will be color-mapped (based on norm and cmap) or and 3D RGB(A)array which will be used as-is) to a rectangular region in dataspace.The orientation of the image in the final rendering is controlled bythe origin and extent kwargs (and attributes on the resultingAxesImage instance) and the data limits of the axes. The extent kwarg controls the bounding box in data coordinates thatthe image will fill specifi...
gridspec
Customizing Figure Layouts Using GridSpec and Other FunctionsHow to create grid-shaped combinations of axes. subplots() GridSpec SubplotSpec subplot2grid() 123import matplotlibimport matplotlib.pyplot as pltimport matplotlib.gridspec as gridspec Basic Quickstart GuideThese first two examples show how to create a basic 2-by-2 grid usingboth subplots() and gridspec. Using subplots() is quite simple.It returns a Figure instance and an array ofAxes objects. 1fig1, f1_axes = plt.subplots(ncols=2,...
legend_guide
Legend guideGenerating legends flexibly in Matplotlib. This legend guide is an extension of the documentation available atlegend() - please ensure you are familiar withcontents of that documentation before proceeding with this guide. This guide makes use of some common terms, which are documented here for clarity: legend entry legend key legend label legend handle Controlling the legend entriesCalling legend() with no arguments automatically fetches the legendhandles and their associated labe...
tight_layout_guide
Tight Layout guideHow to use tight-layout to fit plots within your figure cleanly. tight_layout automatically adjusts subplot params so that thesubplot(s) fits in to the figure area. This is an experimentalfeature and may not work for some cases. It only checks the extentsof ticklabels, axis labels, and titles. An alternative to tight_layout is constrained_layout. Simple ExampleIn matplotlib, the location of axes (including subplots) are specified innormalized figure coordinates. It can happe...
download
所有示例的下载 下载python源码: tutorials_python.py 下载Jupyter notebook: tutorials_jupyter.ipynb
images
Image tutorialA short tutorial on plotting images with Matplotlib. Startup commandsFirst, let’s start IPython. It is a most excellent enhancement to thestandard Python prompt, and it ties in especially well withMatplotlib. Start IPython either at a shell, or the IPython Notebook now. With IPython started, we now need to connect to a GUI event loop. Thistells IPython where (and how) to display plots. To connect to a GUIloop, execute the %matplotlib magic at your IPython prompt. There’s moredet...
customizing
Customizing Matplotlib with style sheets and rcParamsTips for customizing the properties and default styles of Matplotlib. Using style sheetsThe style package adds support for easy-to-switch plotting “styles” withthe same parameters as amatplotlib rc file (which is readat startup to configure matplotlib). There are a number of pre-defined styles provided by Matplotlib. Forexample, there’s a pre-defined style called “ggplot”, which emulates theaesthetics of ggplot (a popular plotting package f...
lifecycle
The Lifecycle of a PlotThis tutorial aims to show the beginning, middle, and end of a singlevisualization using Matplotlib. We’ll begin with some raw data andend by saving a figure of a customized visualization. Along the way we’ll tryto highlight some neat features and best-practices using Matplotlib. ::: tip Note This tutorial is based off ofthis excellent blog postby Chris Moffitt. It was transformed into this tutorial by Chris Holdgraf. ::: A note on the Object-Oriented API vs PyplotMatpl...
sample_plots
Sample plots in MatplotlibHere you’ll find a host of example plots with the code thatgenerated them. Line PlotHere’s how to create a line plot with text labels usingplot(). Simple Plot Multiple subplots in one figureMultiple axes (i.e. subplots) are created with thesubplot() function: Subplot ImagesMatplotlib can display images (assuming equally spacedhorizontal dimensions) using the imshow() function. Example of using imshow() to ...














