subplots ( 2, 2, sharex = True, sharey = True ) # Creates figure number 10 with a single subplot # and clears it if it already exists. subplots ( 2, 2, sharex = 'all', sharey = 'all' ) # Note that this is the same as plt. Matplotlib subplot method is a convenience function provided to create more than one plot in a single figure. We can also add figure-level x- and y-labels using FigureBase.supxlabel and FigureBase. Each axes can have a title (or actually three - one each with loc 'left', 'center', and 'right'), but is sometimes desirable to give a whole figure (or SubFigure) an overall title, using FigureBase.suptitle. subplots ( 2, 2, sharey = 'row' ) # Share both X and Y axes with all subplots plt. Figure labels: suptitle, supxlabel, supylabel. subplots ( 2, 2, sharex = 'col' ) # Share a Y axis with each row of subplots plt. scatter ( x, y ) # Share a X axis with each column of subplots plt. subplots ( 2, 2, subplot_kw = dict ( polar = True )) axes. scatter ( x, y ) # Creates four polar axes, and accesses them through the returned array fig, axes = plt. set_title ( 'Simple plot' ) # Creates two subplots and unpacks the output array immediately f, ( ax1, ax2 ) = plt. sin ( x ** 2 ) # Creates just a figure and only one subplot fig, ax = plt. Since this subplot will overlap the first, the plot (and its axes) previously created, will be removed plt. Theĭimensions of the resulting array can be controlled with the squeeze import matplotlib.pyplot as plt plot a line, implicitly creating a subplot (111) plt.plot( 1,2,3) now create a subplot which represents the top plot of a grid with 2 rows and 1 column. **fig_kwĪll additional keyword arguments are passed to theįig : Figure ax : axes.Axes object or array of Axes objects.Īx can be either a single Axes object or anĪrray of Axes objects if more than one subplot was created. subplot_kw : dict, optionalĭict with keywords passed to the GridSpecĬonstructor used to create the grid the subplots are placed on. Num : integer or string, optional, default: NoneĪ pyplot.figure keyword that sets the figure number or label. If False, no squeezing at all is done: the returned Axes object isĪlways a 2D array containing Axes instances, even if it ends up
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |