API Overview¶
Top Level Functions¶
The main function here is the subplots()
function, but there is also a style
function available (see the styles page).
|
A wrapper to the plt.subplots() function, and is the main way to access the betterplotlib functionality. |
|
Set style settings that will apply to all plots after this function call. |
Axes¶
The Axes_bpl
objects are where the main functionality lies. The easiest
way to create them is by using the subplots()
function, which creates both a
matplotlib Figure and Axes_bpl
object (typically used as
fig, ax = bpl.subplots()). The Axes_bpl
inherits from the
matplotlib Axes object, so it has all the same methods. It additionally has
some new ones, and some of the old ones are redefined to make plotting nicer and
easier. The functionality of the Axes_bpl
is broken down into some common
themes below. Each of these has at least one example of the function in use.
Plotting¶
These methods replace or supplement the default matplotlib commands for the main plotting functionality.
|
A slightly improved plot function. |
|
Makes a scatter plot that looks nicer than the matplotlib default. |
|
Wrapper for the plt.errorbar() function. |
|
A better histogram function. |
|
Visualize a distribution in 1D with kernel density estimation |
|
Creates contours over a 2D histogram of data density. |
|
Creates filled contours over a 2D histogram of data density. |
|
Create a contour plot with scatter points in the sparse regions. |
|
Creates shaded regions showing the density. |
Plot Annotations and Format¶
These methods control various annotations, like the legend, tick marks, and axes labels.
|
Create a nicer looking legend. |
|
Place a horizontal line at some point on the axes. |
|
Place a vertical line at some point on the axes. |
|
Adds text to the specified location. |
|
Adds text in common spots easily. |
|
Set axes limits for both x and y axis at once. |
|
Set tick marks on an axis, with optional label names |
|
Set the x and/or y axis to be log-scaled |
|
Adds labels to the x and y axis, plus a title. |
|
Removes the labels and tick marks from an axis border. |
|
Removes ticks from the given locations. |
|
Remove spines from the axis. |
Makes the x and y axes have the same scale. |
|
|
Creates a differently scaled axis on either the top or the left. |
|
Create a twin axis, where the new axis values are an arbitrary function of the old values. |
|
Turns an axis into one with a dark background with white gridlines. |
|
Puts tiny ticks on the axis borders making the location of each point. |
Non Object-Oriented Interface¶
In addition to the interface described above, all the Axes objects are accessible without directly creating them. This works just like the plt.whatever() syntax in default matplotlib, just with bpl.whatever().
Colors¶
The bpl.color_cycle attribute is a list of colors that I set as the default color cycle for plots. There are also a few other colors mentioned in the styles page. There are also few functions that can be used to handle colors and colormaps.
|
Create a ScalarMappable, which is used to get colors from a colorbar |
|
Create a faded version of a different color |
|
Undo the fading applied by fade_color |