doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
button1(event)[source]
Process an button-1 event (add a label to a contour). Parameters
eventMouseEvent | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingContourLabeler.button1 |
button3(event)[source]
Process an button-3 event (remove a label if not in inline mode). Unfortunately, if one is doing inline labels, then there is currently no way to fix the broken contour - once humpty-dumpty is broken, he can't be put back together. In inline mode, this does nothing. Parameters
eventMouseEvent | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingContourLabeler.button3 |
pop_click(event, index=- 1)[source]
Remove a click (by default, the last) from the list of clicks. Parameters
eventMouseEvent | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingContourLabeler.pop_click |
classmatplotlib.blocking_input.BlockingInput(fig, eventslist=())[source]
Bases: object Callable for retrieving events in a blocking way. add_event(event)[source]
For base class, this just appends an event to events.
cleanup()[source]
Disconnect all callbacks.
on_event(event)[source]
Event handler; will be passed to the current figure to retrieve events.
pop(index=- 1)[source]
Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception.
pop_event(index=- 1)[source]
Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception.
post_event()[source]
For baseclass, do nothing but collect events. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingInput |
add_event(event)[source]
For base class, this just appends an event to events. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingInput.add_event |
cleanup()[source]
Disconnect all callbacks. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingInput.cleanup |
on_event(event)[source]
Event handler; will be passed to the current figure to retrieve events. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingInput.on_event |
pop(index=- 1)[source]
Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingInput.pop |
pop_event(index=- 1)[source]
Remove an event from the event list -- by default, the last. Note that this does not check that there are events, much like the normal pop method. If no events exist, this will throw an exception. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingInput.pop_event |
post_event()[source]
For baseclass, do nothing but collect events. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingInput.post_event |
classmatplotlib.blocking_input.BlockingKeyMouseInput(fig)[source]
Bases: matplotlib.blocking_input.BlockingInput Callable for retrieving mouse clicks and key presses in a blocking way. post_event()[source]
Determine if it is a key event. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingKeyMouseInput |
post_event()[source]
Determine if it is a key event. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingKeyMouseInput.post_event |
classmatplotlib.blocking_input.BlockingMouseInput(fig, mouse_add=MouseButton.LEFT, mouse_pop=MouseButton.RIGHT, mouse_stop=MouseButton.MIDDLE)[source]
Bases: matplotlib.blocking_input.BlockingInput Callable for retrieving mouse clicks in a blocking way. This class will also retrieve keypresses and map them to mouse clicks: delete and backspace are a right click, enter is like a middle click, and all others are like a left click. add_click(event)[source]
Add the coordinates of an event to the list of clicks. Parameters
eventMouseEvent
button_add=1[source]
button_pop=3[source]
button_stop=2[source]
cleanup(event=None)[source]
Parameters
eventMouseEvent, optional
Not used
key_event()[source]
Process a key press event, mapping keys to appropriate mouse clicks.
mouse_event()[source]
Process a mouse click event.
mouse_event_add(event)[source]
Process an button-1 event (add a click if inside axes). Parameters
eventMouseEvent
mouse_event_pop(event)[source]
Process an button-3 event (remove the last click). Parameters
eventMouseEvent
mouse_event_stop(event)[source]
Process an button-2 event (end blocking input). Parameters
eventMouseEvent
pop(event, index=- 1)[source]
Remove a click and the associated event from the list of clicks. Defaults to the last click.
pop_click(event, index=- 1)[source]
Remove a click (by default, the last) from the list of clicks. Parameters
eventMouseEvent
post_event()[source]
Process an event. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput |
add_click(event)[source]
Add the coordinates of an event to the list of clicks. Parameters
eventMouseEvent | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.add_click |
button_add=1[source] | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.button_add |
button_pop=3[source] | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.button_pop |
button_stop=2[source] | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.button_stop |
cleanup(event=None)[source]
Parameters
eventMouseEvent, optional
Not used | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.cleanup |
key_event()[source]
Process a key press event, mapping keys to appropriate mouse clicks. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.key_event |
mouse_event()[source]
Process a mouse click event. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.mouse_event |
mouse_event_add(event)[source]
Process an button-1 event (add a click if inside axes). Parameters
eventMouseEvent | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.mouse_event_add |
mouse_event_pop(event)[source]
Process an button-3 event (remove the last click). Parameters
eventMouseEvent | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.mouse_event_pop |
mouse_event_stop(event)[source]
Process an button-2 event (end blocking input). Parameters
eventMouseEvent | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.mouse_event_stop |
pop(event, index=- 1)[source]
Remove a click and the associated event from the list of clicks. Defaults to the last click. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.pop |
pop_click(event, index=- 1)[source]
Remove a click (by default, the last) from the list of clicks. Parameters
eventMouseEvent | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.pop_click |
post_event()[source]
Process an event. | matplotlib.blocking_input_api#matplotlib.blocking_input.BlockingMouseInput.post_event |
matplotlib.category Plotting of string "category" data: plot(['d', 'f', 'a'], [1, 2, 3]) will plot three points with x-axis values of 'd', 'f', 'a'. See Plotting categorical variables for an example. The module uses Matplotlib's matplotlib.units mechanism to convert from strings to integers and provides a tick locator, a tick formatter, and the UnitData class that creates and stores the string-to-integer mapping. classmatplotlib.category.StrCategoryConverter[source]
Bases: matplotlib.units.ConversionInterface staticaxisinfo(unit, axis)[source]
Set the default axis ticks and labels. Parameters
unitUnitData
object string unit information for value
axisAxis
axis for which information is being set Note axis is not used Returns
AxisInfo
Information to support default tick labeling
staticconvert(value, unit, axis)[source]
Convert strings in value to floats using mapping information stored in the unit object. Parameters
valuestr or iterable
Value or list of values to be converted.
unitUnitData
An object mapping strings to integers.
axisAxis
The axis on which the converted value is plotted. Note axis is unused. Returns
float or ndarray[float]
staticdefault_units(data, axis)[source]
Set and update the Axis units. Parameters
datastr or iterable of str
axisAxis
axis on which the data is plotted Returns
UnitData
object storing string to integer mapping
classmatplotlib.category.StrCategoryFormatter(units_mapping)[source]
Bases: matplotlib.ticker.Formatter String representation of the data at every tick. Parameters
units_mappingdict
Mapping of category names (str) to indices (int). format_ticks(values)[source]
Return the tick labels for all the ticks at once.
classmatplotlib.category.StrCategoryLocator(units_mapping)[source]
Bases: matplotlib.ticker.Locator Tick at every integer mapping of the string data. Parameters
units_mappingdict
Mapping of category names (str) to indices (int). tick_values(vmin, vmax)[source]
Return the values of the located ticks given vmin and vmax. Note To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance: >>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]
classmatplotlib.category.UnitData(data=None)[source]
Bases: object Create mapping between unique categorical values and integer ids. Parameters
dataiterable
sequence of string values update(data)[source]
Map new values to integer identifiers. Parameters
dataiterable of str or bytes
Raises
TypeError
If elements in data are neither str nor bytes. | matplotlib.category_api |
classmatplotlib.category.StrCategoryConverter[source]
Bases: matplotlib.units.ConversionInterface staticaxisinfo(unit, axis)[source]
Set the default axis ticks and labels. Parameters
unitUnitData
object string unit information for value
axisAxis
axis for which information is being set Note axis is not used Returns
AxisInfo
Information to support default tick labeling
staticconvert(value, unit, axis)[source]
Convert strings in value to floats using mapping information stored in the unit object. Parameters
valuestr or iterable
Value or list of values to be converted.
unitUnitData
An object mapping strings to integers.
axisAxis
The axis on which the converted value is plotted. Note axis is unused. Returns
float or ndarray[float]
staticdefault_units(data, axis)[source]
Set and update the Axis units. Parameters
datastr or iterable of str
axisAxis
axis on which the data is plotted Returns
UnitData
object storing string to integer mapping | matplotlib.category_api#matplotlib.category.StrCategoryConverter |
staticaxisinfo(unit, axis)[source]
Set the default axis ticks and labels. Parameters
unitUnitData
object string unit information for value
axisAxis
axis for which information is being set Note axis is not used Returns
AxisInfo
Information to support default tick labeling | matplotlib.category_api#matplotlib.category.StrCategoryConverter.axisinfo |
staticconvert(value, unit, axis)[source]
Convert strings in value to floats using mapping information stored in the unit object. Parameters
valuestr or iterable
Value or list of values to be converted.
unitUnitData
An object mapping strings to integers.
axisAxis
The axis on which the converted value is plotted. Note axis is unused. Returns
float or ndarray[float] | matplotlib.category_api#matplotlib.category.StrCategoryConverter.convert |
staticdefault_units(data, axis)[source]
Set and update the Axis units. Parameters
datastr or iterable of str
axisAxis
axis on which the data is plotted Returns
UnitData
object storing string to integer mapping | matplotlib.category_api#matplotlib.category.StrCategoryConverter.default_units |
classmatplotlib.category.StrCategoryFormatter(units_mapping)[source]
Bases: matplotlib.ticker.Formatter String representation of the data at every tick. Parameters
units_mappingdict
Mapping of category names (str) to indices (int). format_ticks(values)[source]
Return the tick labels for all the ticks at once. | matplotlib.category_api#matplotlib.category.StrCategoryFormatter |
format_ticks(values)[source]
Return the tick labels for all the ticks at once. | matplotlib.category_api#matplotlib.category.StrCategoryFormatter.format_ticks |
classmatplotlib.category.StrCategoryLocator(units_mapping)[source]
Bases: matplotlib.ticker.Locator Tick at every integer mapping of the string data. Parameters
units_mappingdict
Mapping of category names (str) to indices (int). tick_values(vmin, vmax)[source]
Return the values of the located ticks given vmin and vmax. Note To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance: >>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4] | matplotlib.category_api#matplotlib.category.StrCategoryLocator |
tick_values(vmin, vmax)[source]
Return the values of the located ticks given vmin and vmax. Note To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance: >>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4] | matplotlib.category_api#matplotlib.category.StrCategoryLocator.tick_values |
classmatplotlib.category.UnitData(data=None)[source]
Bases: object Create mapping between unique categorical values and integer ids. Parameters
dataiterable
sequence of string values update(data)[source]
Map new values to integer identifiers. Parameters
dataiterable of str or bytes
Raises
TypeError
If elements in data are neither str nor bytes. | matplotlib.category_api#matplotlib.category.UnitData |
update(data)[source]
Map new values to integer identifiers. Parameters
dataiterable of str or bytes
Raises
TypeError
If elements in data are neither str nor bytes. | matplotlib.category_api#matplotlib.category.UnitData.update |
matplotlib.cbook A collection of utility functions and classes. Originally, many (but not all) were from the Python Cookbook -- hence the name cbook. This module is safe to import from anywhere within Matplotlib; it imports Matplotlib only at runtime. classmatplotlib.cbook.CallbackRegistry(exception_handler=<function _exception_printer>)[source]
Bases: object Handle registering, processing, blocking, and disconnecting for a set of signals and callbacks: >>> def oneat(x):
... print('eat', x)
>>> def ondrink(x):
... print('drink', x)
>>> from matplotlib.cbook import CallbackRegistry
>>> callbacks = CallbackRegistry()
>>> id_eat = callbacks.connect('eat', oneat)
>>> id_drink = callbacks.connect('drink', ondrink)
>>> callbacks.process('drink', 123)
drink 123
>>> callbacks.process('eat', 456)
eat 456
>>> callbacks.process('be merry', 456) # nothing will be called
>>> callbacks.disconnect(id_eat)
>>> callbacks.process('eat', 456) # nothing will be called
>>> with callbacks.blocked(signal='drink'):
... callbacks.process('drink', 123) # nothing will be called
>>> callbacks.process('drink', 123)
drink 123
In practice, one should always disconnect all callbacks when they are no longer needed to avoid dangling references (and thus memory leaks). However, real code in Matplotlib rarely does so, and due to its design, it is rather difficult to place this kind of code. To get around this, and prevent this class of memory leaks, we instead store weak references to bound methods only, so when the destination object needs to die, the CallbackRegistry won't keep it alive. Parameters
exception_handlercallable, optional
If not None, exception_handler must be a function that takes an Exception as single parameter. It gets called with any Exception raised by the callbacks during CallbackRegistry.process, and may either re-raise the exception or handle it in another manner. The default handler prints the exception (with traceback.print_exc) if an interactive event loop is running; it re-raises the exception if no interactive event loop is running. blocked(*, signal=None)
Block callback signals from being processed. A context manager to temporarily block/disable callback signals from being processed by the registered listeners. Parameters
signalstr, optional
The callback signal to block. The default is to block all signals.
connect(signal, func)[source]
Register func to be called when signal signal is generated.
disconnect(cid)[source]
Disconnect the callback registered with callback id cid. No error is raised if such a callback does not exist.
process(s, *args, **kwargs)[source]
Process signal s. All of the functions registered to receive callbacks on s will be called with *args and **kwargs.
classmatplotlib.cbook.Grouper(init=())[source]
Bases: object A disjoint-set data structure. Objects can be joined using join(), tested for connectedness using joined(), and all disjoint sets can be retrieved by using the object as an iterator. The objects being joined must be hashable and weak-referenceable. Examples >>> from matplotlib.cbook import Grouper
>>> class Foo:
... def __init__(self, s):
... self.s = s
... def __repr__(self):
... return self.s
...
>>> a, b, c, d, e, f = [Foo(x) for x in 'abcdef']
>>> grp = Grouper()
>>> grp.join(a, b)
>>> grp.join(b, c)
>>> grp.join(d, e)
>>> list(grp)
[[a, b, c], [d, e]]
>>> grp.joined(a, b)
True
>>> grp.joined(a, c)
True
>>> grp.joined(a, d)
False
clean()[source]
Clean dead weak references from the dictionary.
get_siblings(a)[source]
Return all of the items joined with a, including itself.
join(a, *args)[source]
Join given arguments into the same set. Accepts one or more arguments.
joined(a, b)[source]
Return whether a and b are members of the same set.
remove(a)[source]
classmatplotlib.cbook.Stack(default=None)[source]
Bases: object Stack of elements with a movable cursor. Mimics home/back/forward in a web browser. back()[source]
Move the position back and return the current element.
bubble(o)[source]
Raise all references of o to the top of the stack, and return it. Raises
ValueError
If o is not in the stack.
clear()[source]
Empty the stack.
empty()[source]
Return whether the stack is empty.
forward()[source]
Move the position forward and return the current element.
home()[source]
Push the first element onto the top of the stack. The first element is returned.
push(o)[source]
Push o to the stack at current position. Discard all later elements. o is returned.
remove(o)[source]
Remove o from the stack. Raises
ValueError
If o is not in the stack.
matplotlib.cbook.boxplot_stats(X, whis=1.5, bootstrap=None, labels=None, autorange=False)[source]
Return a list of dictionaries of statistics used to draw a series of box and whisker plots using bxp. Parameters
Xarray-like
Data that will be represented in the boxplots. Should have 2 or fewer dimensions.
whisfloat or (float, float), default: 1.5
The position of the whiskers. If a float, the lower whisker is at the lowest datum above Q1 - whis*(Q3-Q1), and the upper whisker at the highest datum below Q3 + whis*(Q3-Q1), where Q1 and Q3 are the first and third quartiles. The default value of whis = 1.5 corresponds to Tukey's original definition of boxplots. If a pair of floats, they indicate the percentiles at which to draw the whiskers (e.g., (5, 95)). In particular, setting this to (0, 100) results in whiskers covering the whole range of the data. In the edge case where Q1 == Q3, whis is automatically set to (0, 100) (cover the whole range of the data) if autorange is True. Beyond the whiskers, data are considered outliers and are plotted as individual points.
bootstrapint, optional
Number of times the confidence intervals around the median should be bootstrapped (percentile method).
labelsarray-like, optional
Labels for each dataset. Length must be compatible with dimensions of X.
autorangebool, optional (False)
When True and the data are distributed such that the 25th and 75th percentiles are equal, whis is set to (0, 100) such that the whisker ends are at the minimum and maximum of the data. Returns
list of dict
A list of dictionaries containing the results for each column of data. Keys of each dictionary are the following:
Key Value Description
label tick label for the boxplot
mean arithmetic mean value
med 50th percentile
q1 first quartile (25th percentile)
q3 third quartile (75th percentile)
cilo lower notch around the median
cihi upper notch around the median
whislo end of the lower whisker
whishi end of the upper whisker
fliers outliers Notes Non-bootstrapping approach to confidence interval uses Gaussian-based asymptotic approximation: \[\mathrm{med} \pm 1.57 \times \frac{\mathrm{iqr}}{\sqrt{N}}\] General approach from: McGill, R., Tukey, J.W., and Larsen, W.A. (1978) "Variations of Boxplots", The American Statistician, 32:12-16.
matplotlib.cbook.contiguous_regions(mask)[source]
Return a list of (ind0, ind1) such that mask[ind0:ind1].all() is True and we cover all such regions.
matplotlib.cbook.delete_masked_points(*args)[source]
Find all masked and/or non-finite points in a set of arguments, and return the arguments with only the unmasked points remaining. Arguments can be in any of 5 categories: 1-D masked arrays 1-D ndarrays ndarrays with more than one dimension other non-string iterables anything else The first argument must be in one of the first four categories; any argument with a length differing from that of the first argument (and hence anything in category 5) then will be passed through unchanged. Masks are obtained from all arguments of the correct length in categories 1, 2, and 4; a point is bad if masked in a masked array or if it is a nan or inf. No attempt is made to extract a mask from categories 2, 3, and 4 if numpy.isfinite does not yield a Boolean array. All input arguments that are not passed unchanged are returned as ndarrays after removing the points or rows corresponding to masks in any of the arguments. A vastly simpler version of this function was originally written as a helper for Axes.scatter().
matplotlib.cbook.deprecated(*args, **kwargs)[source]
[Deprecated] Notes Deprecated since version 3.4:
matplotlib.cbook.file_requires_unicode(x)[source]
Return whether the given writable file-like object requires Unicode to be written to it.
matplotlib.cbook.flatten(seq, scalarp=<function is_scalar_or_string>)[source]
Return a generator of flattened nested containers. For example: >>> from matplotlib.cbook import flatten
>>> l = (('John', ['Hunter']), (1, 23), [[([42, (5, 23)], )]])
>>> print(list(flatten(l)))
['John', 'Hunter', 1, 23, 42, 5, 23]
By: Composite of Holger Krekel and Luther Blissett From: https://code.activestate.com/recipes/121294/ and Recipe 1.12 in cookbook
matplotlib.cbook.get_sample_data(fname, asfileobj=True, *, np_load=False)[source]
Return a sample data file. fname is a path relative to the mpl-data/sample_data directory. If asfileobj is True return a file object, otherwise just a file path. Sample data files are stored in the 'mpl-data/sample_data' directory within the Matplotlib package. If the filename ends in .gz, the file is implicitly ungzipped. If the filename ends with .npy or .npz, asfileobj is True, and np_load is True, the file is loaded with numpy.load. np_load currently defaults to False but will default to True in a future release.
matplotlib.cbook.index_of(y)[source]
A helper function to create reasonable x values for the given y. This is used for plotting (x, y) if x values are not explicitly given. First try y.index (assuming y is a pandas.Series), if that fails, use range(len(y)). This will be extended in the future to deal with more types of labeled data. Parameters
yfloat or array-like
Returns
x, yndarray
The x and y values to plot.
matplotlib.cbook.is_math_text(s)[source]
Return whether the string s contains math expressions. This is done by checking whether s contains an even number of non-escaped dollar signs.
matplotlib.cbook.is_scalar_or_string(val)[source]
Return whether the given object is a scalar or string like.
matplotlib.cbook.is_writable_file_like(obj)[source]
Return whether obj looks like a file object with a write method.
matplotlib.cbook.ls_mapper={'-': 'solid', '--': 'dashed', '-.': 'dashdot', ':': 'dotted'}
Maps short codes for line style to their full name used by backends.
matplotlib.cbook.ls_mapper_r={'dashdot': '-.', 'dashed': '--', 'dotted': ':', 'solid': '-'}
Maps full names for line styles used by backends to their short codes.
classmatplotlib.cbook.maxdict(maxsize)[source]
Bases: dict A dictionary with a maximum size. Notes This doesn't override all the relevant methods to constrain the size, just __setitem__, so use with caution.
matplotlib.cbook.normalize_kwargs(kw, alias_mapping=None)[source]
Helper function to normalize kwarg inputs. Parameters
kwdict or None
A dict of keyword arguments. None is explicitly supported and treated as an empty dict, to support functions with an optional parameter of the form props=None.
alias_mappingdict or Artist subclass or Artist instance, optional
A mapping between a canonical name to a list of aliases, in order of precedence from lowest to highest. If the canonical value is not in the list it is assumed to have the highest priority. If an Artist subclass or instance is passed, use its properties alias mapping. Raises
TypeError
To match what Python raises if invalid arguments/keyword arguments are passed to a callable.
matplotlib.cbook.open_file_cm(path_or_file, mode='r', encoding=None)[source]
Pass through file objects and context-manage path-likes.
matplotlib.cbook.print_cycles(objects, outstream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, show_progress=False)[source]
Print loops of cyclic references in the given objects. It is often useful to pass in gc.garbage to find the cycles that are preventing some objects from being garbage collected. Parameters
objects
A list of objects to find cycles in. outstream
The stream for output.
show_progressbool
If True, print the number of objects reached as they are found.
matplotlib.cbook.pts_to_midstep(x, *args)[source]
Convert continuous line to mid-steps. Given a set of N points convert to 2N points which when connected linearly give a step function which changes values at the middle of the intervals. Parameters
xarray
The x location of the steps. May be empty.
y1, ..., yparray
y arrays to be turned into steps; all must be the same length as x. Returns
array
The x and y values converted to steps in the same order as the input; can be unpacked as x_out, y1_out, ..., yp_out. If the input is length N, each of these arrays will be length 2N. Examples >>> x_s, y1_s, y2_s = pts_to_midstep(x, y1, y2)
matplotlib.cbook.pts_to_poststep(x, *args)[source]
Convert continuous line to post-steps. Given a set of N points convert to 2N + 1 points, which when connected linearly give a step function which changes values at the end of the intervals. Parameters
xarray
The x location of the steps. May be empty.
y1, ..., yparray
y arrays to be turned into steps; all must be the same length as x. Returns
array
The x and y values converted to steps in the same order as the input; can be unpacked as x_out, y1_out, ..., yp_out. If the input is length N, each of these arrays will be length 2N + 1. For N=0, the length will be 0. Examples >>> x_s, y1_s, y2_s = pts_to_poststep(x, y1, y2)
matplotlib.cbook.pts_to_prestep(x, *args)[source]
Convert continuous line to pre-steps. Given a set of N points, convert to 2N - 1 points, which when connected linearly give a step function which changes values at the beginning of the intervals. Parameters
xarray
The x location of the steps. May be empty.
y1, ..., yparray
y arrays to be turned into steps; all must be the same length as x. Returns
array
The x and y values converted to steps in the same order as the input; can be unpacked as x_out, y1_out, ..., yp_out. If the input is length N, each of these arrays will be length 2N + 1. For N=0, the length will be 0. Examples >>> x_s, y1_s, y2_s = pts_to_prestep(x, y1, y2)
matplotlib.cbook.report_memory(i=0)[source]
[Deprecated] Return the memory consumed by the process. Notes Deprecated since version 3.5.
matplotlib.cbook.safe_first_element(obj)[source]
Return the first element in obj. This is an type-independent way of obtaining the first element, supporting both index access and the iterator protocol.
matplotlib.cbook.safe_masked_invalid(x, copy=False)[source]
matplotlib.cbook.sanitize_sequence(data)[source]
Convert dictview objects to list. Other inputs are returned unchanged.
classmatplotlib.cbook.silent_list(type, seq=None)[source]
Bases: list A list with a short repr(). This is meant to be used for a homogeneous list of artists, so that they don't cause long, meaningless output. Instead of [<matplotlib.lines.Line2D object at 0x7f5749fed3c8>,
<matplotlib.lines.Line2D object at 0x7f5749fed4e0>,
<matplotlib.lines.Line2D object at 0x7f5758016550>]
one will get <a list of 3 Line2D objects>
If self.type is None, the type name is obtained from the first item in the list (if any).
matplotlib.cbook.simple_linear_interpolation(a, steps)[source]
Resample an array with steps - 1 points between original point pairs. Along each column of a, (steps - 1) points are introduced between each original values; the values are linearly interpolated. Parameters
aarray, shape (n, ...)
stepsint
Returns
array
shape ((n - 1) * steps + 1, ...)
matplotlib.cbook.strip_math(s)[source]
Remove latex formatting from mathtext. Only handles fully math and fully non-math strings.
matplotlib.cbook.to_filehandle(fname, flag='r', return_opened=False, encoding=None)[source]
Convert a path to an open file handle or pass-through a file-like object. Consider using open_file_cm instead, as it allows one to properly close newly created file objects more easily. Parameters
fnamestr or path-like or file-like
If str or os.PathLike, the file is opened using the flags specified by flag and encoding. If a file-like object, it is passed through.
flagstr, default: 'r'
Passed as the mode argument to open when fname is str or os.PathLike; ignored if fname is file-like.
return_openedbool, default: False
If True, return both the file object and a boolean indicating whether this was a new file (that the caller needs to close). If False, return only the new file.
encodingstr or None, default: None
Passed as the mode argument to open when fname is str or os.PathLike; ignored if fname is file-like. Returns
fhfile-like
openedbool
opened is only returned if return_opened is True.
matplotlib.cbook.violin_stats(X, method, points=100, quantiles=None)[source]
Return a list of dictionaries of data which can be used to draw a series of violin plots. See the Returns section below to view the required keys of the dictionary. Users can skip this function and pass a user-defined set of dictionaries with the same keys to violinplot instead of using Matplotlib to do the calculations. See the Returns section below for the keys that must be present in the dictionaries. Parameters
Xarray-like
Sample data that will be used to produce the gaussian kernel density estimates. Must have 2 or fewer dimensions.
methodcallable
The method used to calculate the kernel density estimate for each column of data. When called via method(v, coords), it should return a vector of the values of the KDE evaluated at the values specified in coords.
pointsint, default: 100
Defines the number of points to evaluate each of the gaussian kernel density estimates at.
quantilesarray-like, default: None
Defines (if not None) a list of floats in interval [0, 1] for each column of data, which represents the quantiles that will be rendered for that column of data. Must have 2 or fewer dimensions. 1D array will be treated as a singleton list containing them. Returns
list of dict
A list of dictionaries containing the results for each column of data. The dictionaries contain at least the following: coords: A list of scalars containing the coordinates this particular kernel density estimate was evaluated at. vals: A list of scalars containing the values of the kernel density estimate at each of the coordinates given in coords. mean: The mean value for this column of data. median: The median value for this column of data. min: The minimum value for this column of data. max: The maximum value for this column of data. quantiles: The quantile values for this column of data.
matplotlib.cbook.warn_deprecated(*args, **kwargs)[source]
[Deprecated] Notes Deprecated since version 3.4: | matplotlib.cbook_api |
matplotlib.cbook.boxplot_stats(X, whis=1.5, bootstrap=None, labels=None, autorange=False)[source]
Return a list of dictionaries of statistics used to draw a series of box and whisker plots using bxp. Parameters
Xarray-like
Data that will be represented in the boxplots. Should have 2 or fewer dimensions.
whisfloat or (float, float), default: 1.5
The position of the whiskers. If a float, the lower whisker is at the lowest datum above Q1 - whis*(Q3-Q1), and the upper whisker at the highest datum below Q3 + whis*(Q3-Q1), where Q1 and Q3 are the first and third quartiles. The default value of whis = 1.5 corresponds to Tukey's original definition of boxplots. If a pair of floats, they indicate the percentiles at which to draw the whiskers (e.g., (5, 95)). In particular, setting this to (0, 100) results in whiskers covering the whole range of the data. In the edge case where Q1 == Q3, whis is automatically set to (0, 100) (cover the whole range of the data) if autorange is True. Beyond the whiskers, data are considered outliers and are plotted as individual points.
bootstrapint, optional
Number of times the confidence intervals around the median should be bootstrapped (percentile method).
labelsarray-like, optional
Labels for each dataset. Length must be compatible with dimensions of X.
autorangebool, optional (False)
When True and the data are distributed such that the 25th and 75th percentiles are equal, whis is set to (0, 100) such that the whisker ends are at the minimum and maximum of the data. Returns
list of dict
A list of dictionaries containing the results for each column of data. Keys of each dictionary are the following:
Key Value Description
label tick label for the boxplot
mean arithmetic mean value
med 50th percentile
q1 first quartile (25th percentile)
q3 third quartile (75th percentile)
cilo lower notch around the median
cihi upper notch around the median
whislo end of the lower whisker
whishi end of the upper whisker
fliers outliers Notes Non-bootstrapping approach to confidence interval uses Gaussian-based asymptotic approximation: \[\mathrm{med} \pm 1.57 \times \frac{\mathrm{iqr}}{\sqrt{N}}\] General approach from: McGill, R., Tukey, J.W., and Larsen, W.A. (1978) "Variations of Boxplots", The American Statistician, 32:12-16. | matplotlib.cbook_api#matplotlib.cbook.boxplot_stats |
classmatplotlib.cbook.CallbackRegistry(exception_handler=<function _exception_printer>)[source]
Bases: object Handle registering, processing, blocking, and disconnecting for a set of signals and callbacks: >>> def oneat(x):
... print('eat', x)
>>> def ondrink(x):
... print('drink', x)
>>> from matplotlib.cbook import CallbackRegistry
>>> callbacks = CallbackRegistry()
>>> id_eat = callbacks.connect('eat', oneat)
>>> id_drink = callbacks.connect('drink', ondrink)
>>> callbacks.process('drink', 123)
drink 123
>>> callbacks.process('eat', 456)
eat 456
>>> callbacks.process('be merry', 456) # nothing will be called
>>> callbacks.disconnect(id_eat)
>>> callbacks.process('eat', 456) # nothing will be called
>>> with callbacks.blocked(signal='drink'):
... callbacks.process('drink', 123) # nothing will be called
>>> callbacks.process('drink', 123)
drink 123
In practice, one should always disconnect all callbacks when they are no longer needed to avoid dangling references (and thus memory leaks). However, real code in Matplotlib rarely does so, and due to its design, it is rather difficult to place this kind of code. To get around this, and prevent this class of memory leaks, we instead store weak references to bound methods only, so when the destination object needs to die, the CallbackRegistry won't keep it alive. Parameters
exception_handlercallable, optional
If not None, exception_handler must be a function that takes an Exception as single parameter. It gets called with any Exception raised by the callbacks during CallbackRegistry.process, and may either re-raise the exception or handle it in another manner. The default handler prints the exception (with traceback.print_exc) if an interactive event loop is running; it re-raises the exception if no interactive event loop is running. blocked(*, signal=None)
Block callback signals from being processed. A context manager to temporarily block/disable callback signals from being processed by the registered listeners. Parameters
signalstr, optional
The callback signal to block. The default is to block all signals.
connect(signal, func)[source]
Register func to be called when signal signal is generated.
disconnect(cid)[source]
Disconnect the callback registered with callback id cid. No error is raised if such a callback does not exist.
process(s, *args, **kwargs)[source]
Process signal s. All of the functions registered to receive callbacks on s will be called with *args and **kwargs. | matplotlib.cbook_api#matplotlib.cbook.CallbackRegistry |
blocked(*, signal=None)
Block callback signals from being processed. A context manager to temporarily block/disable callback signals from being processed by the registered listeners. Parameters
signalstr, optional
The callback signal to block. The default is to block all signals. | matplotlib.cbook_api#matplotlib.cbook.CallbackRegistry.blocked |
connect(signal, func)[source]
Register func to be called when signal signal is generated. | matplotlib.cbook_api#matplotlib.cbook.CallbackRegistry.connect |
disconnect(cid)[source]
Disconnect the callback registered with callback id cid. No error is raised if such a callback does not exist. | matplotlib.cbook_api#matplotlib.cbook.CallbackRegistry.disconnect |
process(s, *args, **kwargs)[source]
Process signal s. All of the functions registered to receive callbacks on s will be called with *args and **kwargs. | matplotlib.cbook_api#matplotlib.cbook.CallbackRegistry.process |
matplotlib.cbook.contiguous_regions(mask)[source]
Return a list of (ind0, ind1) such that mask[ind0:ind1].all() is True and we cover all such regions. | matplotlib.cbook_api#matplotlib.cbook.contiguous_regions |
matplotlib.cbook.delete_masked_points(*args)[source]
Find all masked and/or non-finite points in a set of arguments, and return the arguments with only the unmasked points remaining. Arguments can be in any of 5 categories: 1-D masked arrays 1-D ndarrays ndarrays with more than one dimension other non-string iterables anything else The first argument must be in one of the first four categories; any argument with a length differing from that of the first argument (and hence anything in category 5) then will be passed through unchanged. Masks are obtained from all arguments of the correct length in categories 1, 2, and 4; a point is bad if masked in a masked array or if it is a nan or inf. No attempt is made to extract a mask from categories 2, 3, and 4 if numpy.isfinite does not yield a Boolean array. All input arguments that are not passed unchanged are returned as ndarrays after removing the points or rows corresponding to masks in any of the arguments. A vastly simpler version of this function was originally written as a helper for Axes.scatter(). | matplotlib.cbook_api#matplotlib.cbook.delete_masked_points |
matplotlib.cbook.deprecated(*args, **kwargs)[source]
[Deprecated] Notes Deprecated since version 3.4: | matplotlib.cbook_api#matplotlib.cbook.deprecated |
matplotlib.cbook.file_requires_unicode(x)[source]
Return whether the given writable file-like object requires Unicode to be written to it. | matplotlib.cbook_api#matplotlib.cbook.file_requires_unicode |
matplotlib.cbook.flatten(seq, scalarp=<function is_scalar_or_string>)[source]
Return a generator of flattened nested containers. For example: >>> from matplotlib.cbook import flatten
>>> l = (('John', ['Hunter']), (1, 23), [[([42, (5, 23)], )]])
>>> print(list(flatten(l)))
['John', 'Hunter', 1, 23, 42, 5, 23]
By: Composite of Holger Krekel and Luther Blissett From: https://code.activestate.com/recipes/121294/ and Recipe 1.12 in cookbook | matplotlib.cbook_api#matplotlib.cbook.flatten |
matplotlib.cbook.get_sample_data(fname, asfileobj=True, *, np_load=False)[source]
Return a sample data file. fname is a path relative to the mpl-data/sample_data directory. If asfileobj is True return a file object, otherwise just a file path. Sample data files are stored in the 'mpl-data/sample_data' directory within the Matplotlib package. If the filename ends in .gz, the file is implicitly ungzipped. If the filename ends with .npy or .npz, asfileobj is True, and np_load is True, the file is loaded with numpy.load. np_load currently defaults to False but will default to True in a future release. | matplotlib.cbook_api#matplotlib.cbook.get_sample_data |
classmatplotlib.cbook.Grouper(init=())[source]
Bases: object A disjoint-set data structure. Objects can be joined using join(), tested for connectedness using joined(), and all disjoint sets can be retrieved by using the object as an iterator. The objects being joined must be hashable and weak-referenceable. Examples >>> from matplotlib.cbook import Grouper
>>> class Foo:
... def __init__(self, s):
... self.s = s
... def __repr__(self):
... return self.s
...
>>> a, b, c, d, e, f = [Foo(x) for x in 'abcdef']
>>> grp = Grouper()
>>> grp.join(a, b)
>>> grp.join(b, c)
>>> grp.join(d, e)
>>> list(grp)
[[a, b, c], [d, e]]
>>> grp.joined(a, b)
True
>>> grp.joined(a, c)
True
>>> grp.joined(a, d)
False
clean()[source]
Clean dead weak references from the dictionary.
get_siblings(a)[source]
Return all of the items joined with a, including itself.
join(a, *args)[source]
Join given arguments into the same set. Accepts one or more arguments.
joined(a, b)[source]
Return whether a and b are members of the same set.
remove(a)[source] | matplotlib.cbook_api#matplotlib.cbook.Grouper |
clean()[source]
Clean dead weak references from the dictionary. | matplotlib.cbook_api#matplotlib.cbook.Grouper.clean |
get_siblings(a)[source]
Return all of the items joined with a, including itself. | matplotlib.cbook_api#matplotlib.cbook.Grouper.get_siblings |
join(a, *args)[source]
Join given arguments into the same set. Accepts one or more arguments. | matplotlib.cbook_api#matplotlib.cbook.Grouper.join |
joined(a, b)[source]
Return whether a and b are members of the same set. | matplotlib.cbook_api#matplotlib.cbook.Grouper.joined |
remove(a)[source] | matplotlib.cbook_api#matplotlib.cbook.Grouper.remove |
matplotlib.cbook.index_of(y)[source]
A helper function to create reasonable x values for the given y. This is used for plotting (x, y) if x values are not explicitly given. First try y.index (assuming y is a pandas.Series), if that fails, use range(len(y)). This will be extended in the future to deal with more types of labeled data. Parameters
yfloat or array-like
Returns
x, yndarray
The x and y values to plot. | matplotlib.cbook_api#matplotlib.cbook.index_of |
matplotlib.cbook.is_math_text(s)[source]
Return whether the string s contains math expressions. This is done by checking whether s contains an even number of non-escaped dollar signs. | matplotlib.cbook_api#matplotlib.cbook.is_math_text |
matplotlib.cbook.is_scalar_or_string(val)[source]
Return whether the given object is a scalar or string like. | matplotlib.cbook_api#matplotlib.cbook.is_scalar_or_string |
matplotlib.cbook.is_writable_file_like(obj)[source]
Return whether obj looks like a file object with a write method. | matplotlib.cbook_api#matplotlib.cbook.is_writable_file_like |
matplotlib.cbook.ls_mapper={'-': 'solid', '--': 'dashed', '-.': 'dashdot', ':': 'dotted'}
Maps short codes for line style to their full name used by backends. | matplotlib.cbook_api#matplotlib.cbook.ls_mapper |
matplotlib.cbook.ls_mapper_r={'dashdot': '-.', 'dashed': '--', 'dotted': ':', 'solid': '-'}
Maps full names for line styles used by backends to their short codes. | matplotlib.cbook_api#matplotlib.cbook.ls_mapper_r |
classmatplotlib.cbook.maxdict(maxsize)[source]
Bases: dict A dictionary with a maximum size. Notes This doesn't override all the relevant methods to constrain the size, just __setitem__, so use with caution. | matplotlib.cbook_api#matplotlib.cbook.maxdict |
matplotlib.cbook.normalize_kwargs(kw, alias_mapping=None)[source]
Helper function to normalize kwarg inputs. Parameters
kwdict or None
A dict of keyword arguments. None is explicitly supported and treated as an empty dict, to support functions with an optional parameter of the form props=None.
alias_mappingdict or Artist subclass or Artist instance, optional
A mapping between a canonical name to a list of aliases, in order of precedence from lowest to highest. If the canonical value is not in the list it is assumed to have the highest priority. If an Artist subclass or instance is passed, use its properties alias mapping. Raises
TypeError
To match what Python raises if invalid arguments/keyword arguments are passed to a callable. | matplotlib.cbook_api#matplotlib.cbook.normalize_kwargs |
matplotlib.cbook.open_file_cm(path_or_file, mode='r', encoding=None)[source]
Pass through file objects and context-manage path-likes. | matplotlib.cbook_api#matplotlib.cbook.open_file_cm |
matplotlib.cbook.print_cycles(objects, outstream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, show_progress=False)[source]
Print loops of cyclic references in the given objects. It is often useful to pass in gc.garbage to find the cycles that are preventing some objects from being garbage collected. Parameters
objects
A list of objects to find cycles in. outstream
The stream for output.
show_progressbool
If True, print the number of objects reached as they are found. | matplotlib.cbook_api#matplotlib.cbook.print_cycles |
matplotlib.cbook.pts_to_midstep(x, *args)[source]
Convert continuous line to mid-steps. Given a set of N points convert to 2N points which when connected linearly give a step function which changes values at the middle of the intervals. Parameters
xarray
The x location of the steps. May be empty.
y1, ..., yparray
y arrays to be turned into steps; all must be the same length as x. Returns
array
The x and y values converted to steps in the same order as the input; can be unpacked as x_out, y1_out, ..., yp_out. If the input is length N, each of these arrays will be length 2N. Examples >>> x_s, y1_s, y2_s = pts_to_midstep(x, y1, y2) | matplotlib.cbook_api#matplotlib.cbook.pts_to_midstep |
matplotlib.cbook.pts_to_poststep(x, *args)[source]
Convert continuous line to post-steps. Given a set of N points convert to 2N + 1 points, which when connected linearly give a step function which changes values at the end of the intervals. Parameters
xarray
The x location of the steps. May be empty.
y1, ..., yparray
y arrays to be turned into steps; all must be the same length as x. Returns
array
The x and y values converted to steps in the same order as the input; can be unpacked as x_out, y1_out, ..., yp_out. If the input is length N, each of these arrays will be length 2N + 1. For N=0, the length will be 0. Examples >>> x_s, y1_s, y2_s = pts_to_poststep(x, y1, y2) | matplotlib.cbook_api#matplotlib.cbook.pts_to_poststep |
matplotlib.cbook.pts_to_prestep(x, *args)[source]
Convert continuous line to pre-steps. Given a set of N points, convert to 2N - 1 points, which when connected linearly give a step function which changes values at the beginning of the intervals. Parameters
xarray
The x location of the steps. May be empty.
y1, ..., yparray
y arrays to be turned into steps; all must be the same length as x. Returns
array
The x and y values converted to steps in the same order as the input; can be unpacked as x_out, y1_out, ..., yp_out. If the input is length N, each of these arrays will be length 2N + 1. For N=0, the length will be 0. Examples >>> x_s, y1_s, y2_s = pts_to_prestep(x, y1, y2) | matplotlib.cbook_api#matplotlib.cbook.pts_to_prestep |
matplotlib.cbook.report_memory(i=0)[source]
[Deprecated] Return the memory consumed by the process. Notes Deprecated since version 3.5. | matplotlib.cbook_api#matplotlib.cbook.report_memory |
matplotlib.cbook.safe_first_element(obj)[source]
Return the first element in obj. This is an type-independent way of obtaining the first element, supporting both index access and the iterator protocol. | matplotlib.cbook_api#matplotlib.cbook.safe_first_element |
matplotlib.cbook.safe_masked_invalid(x, copy=False)[source] | matplotlib.cbook_api#matplotlib.cbook.safe_masked_invalid |
matplotlib.cbook.sanitize_sequence(data)[source]
Convert dictview objects to list. Other inputs are returned unchanged. | matplotlib.cbook_api#matplotlib.cbook.sanitize_sequence |
classmatplotlib.cbook.silent_list(type, seq=None)[source]
Bases: list A list with a short repr(). This is meant to be used for a homogeneous list of artists, so that they don't cause long, meaningless output. Instead of [<matplotlib.lines.Line2D object at 0x7f5749fed3c8>,
<matplotlib.lines.Line2D object at 0x7f5749fed4e0>,
<matplotlib.lines.Line2D object at 0x7f5758016550>]
one will get <a list of 3 Line2D objects>
If self.type is None, the type name is obtained from the first item in the list (if any). | matplotlib.cbook_api#matplotlib.cbook.silent_list |
matplotlib.cbook.simple_linear_interpolation(a, steps)[source]
Resample an array with steps - 1 points between original point pairs. Along each column of a, (steps - 1) points are introduced between each original values; the values are linearly interpolated. Parameters
aarray, shape (n, ...)
stepsint
Returns
array
shape ((n - 1) * steps + 1, ...) | matplotlib.cbook_api#matplotlib.cbook.simple_linear_interpolation |
classmatplotlib.cbook.Stack(default=None)[source]
Bases: object Stack of elements with a movable cursor. Mimics home/back/forward in a web browser. back()[source]
Move the position back and return the current element.
bubble(o)[source]
Raise all references of o to the top of the stack, and return it. Raises
ValueError
If o is not in the stack.
clear()[source]
Empty the stack.
empty()[source]
Return whether the stack is empty.
forward()[source]
Move the position forward and return the current element.
home()[source]
Push the first element onto the top of the stack. The first element is returned.
push(o)[source]
Push o to the stack at current position. Discard all later elements. o is returned.
remove(o)[source]
Remove o from the stack. Raises
ValueError
If o is not in the stack. | matplotlib.cbook_api#matplotlib.cbook.Stack |
back()[source]
Move the position back and return the current element. | matplotlib.cbook_api#matplotlib.cbook.Stack.back |
bubble(o)[source]
Raise all references of o to the top of the stack, and return it. Raises
ValueError
If o is not in the stack. | matplotlib.cbook_api#matplotlib.cbook.Stack.bubble |
clear()[source]
Empty the stack. | matplotlib.cbook_api#matplotlib.cbook.Stack.clear |
empty()[source]
Return whether the stack is empty. | matplotlib.cbook_api#matplotlib.cbook.Stack.empty |
forward()[source]
Move the position forward and return the current element. | matplotlib.cbook_api#matplotlib.cbook.Stack.forward |
home()[source]
Push the first element onto the top of the stack. The first element is returned. | matplotlib.cbook_api#matplotlib.cbook.Stack.home |
push(o)[source]
Push o to the stack at current position. Discard all later elements. o is returned. | matplotlib.cbook_api#matplotlib.cbook.Stack.push |
remove(o)[source]
Remove o from the stack. Raises
ValueError
If o is not in the stack. | matplotlib.cbook_api#matplotlib.cbook.Stack.remove |
matplotlib.cbook.strip_math(s)[source]
Remove latex formatting from mathtext. Only handles fully math and fully non-math strings. | matplotlib.cbook_api#matplotlib.cbook.strip_math |
matplotlib.cbook.to_filehandle(fname, flag='r', return_opened=False, encoding=None)[source]
Convert a path to an open file handle or pass-through a file-like object. Consider using open_file_cm instead, as it allows one to properly close newly created file objects more easily. Parameters
fnamestr or path-like or file-like
If str or os.PathLike, the file is opened using the flags specified by flag and encoding. If a file-like object, it is passed through.
flagstr, default: 'r'
Passed as the mode argument to open when fname is str or os.PathLike; ignored if fname is file-like.
return_openedbool, default: False
If True, return both the file object and a boolean indicating whether this was a new file (that the caller needs to close). If False, return only the new file.
encodingstr or None, default: None
Passed as the mode argument to open when fname is str or os.PathLike; ignored if fname is file-like. Returns
fhfile-like
openedbool
opened is only returned if return_opened is True. | matplotlib.cbook_api#matplotlib.cbook.to_filehandle |
matplotlib.cbook.violin_stats(X, method, points=100, quantiles=None)[source]
Return a list of dictionaries of data which can be used to draw a series of violin plots. See the Returns section below to view the required keys of the dictionary. Users can skip this function and pass a user-defined set of dictionaries with the same keys to violinplot instead of using Matplotlib to do the calculations. See the Returns section below for the keys that must be present in the dictionaries. Parameters
Xarray-like
Sample data that will be used to produce the gaussian kernel density estimates. Must have 2 or fewer dimensions.
methodcallable
The method used to calculate the kernel density estimate for each column of data. When called via method(v, coords), it should return a vector of the values of the KDE evaluated at the values specified in coords.
pointsint, default: 100
Defines the number of points to evaluate each of the gaussian kernel density estimates at.
quantilesarray-like, default: None
Defines (if not None) a list of floats in interval [0, 1] for each column of data, which represents the quantiles that will be rendered for that column of data. Must have 2 or fewer dimensions. 1D array will be treated as a singleton list containing them. Returns
list of dict
A list of dictionaries containing the results for each column of data. The dictionaries contain at least the following: coords: A list of scalars containing the coordinates this particular kernel density estimate was evaluated at. vals: A list of scalars containing the values of the kernel density estimate at each of the coordinates given in coords. mean: The mean value for this column of data. median: The median value for this column of data. min: The minimum value for this column of data. max: The maximum value for this column of data. quantiles: The quantile values for this column of data. | matplotlib.cbook_api#matplotlib.cbook.violin_stats |
matplotlib.cbook.warn_deprecated(*args, **kwargs)[source]
[Deprecated] Notes Deprecated since version 3.4: | matplotlib.cbook_api#matplotlib.cbook.warn_deprecated |
matplotlib.cm Builtin colormaps, colormap handling utilities, and the ScalarMappable mixin. See also Colormap reference for a list of builtin colormaps. Creating Colormaps in Matplotlib for examples of how to make colormaps. Choosing Colormaps in Matplotlib an in-depth discussion of choosing colormaps. Colormap Normalization for more details about data normalization. classmatplotlib.cm.ColormapRegistry(cmaps)[source]
Bases: collections.abc.Mapping Container for colormaps that are known to Matplotlib by name. Experimental While we expect the API to be final, we formally mark it as experimental for 3.5 because we want to keep the option to still adapt the API for 3.6 should the need arise. The universal registry instance is matplotlib.colormaps. There should be no need for users to instantiate ColormapRegistry themselves. Read access uses a dict-like interface mapping names to Colormaps: import matplotlib as mpl
cmap = mpl.colormaps['viridis']
Returned Colormaps are copies, so that their modification does not change the global definition of the colormap. Additional colormaps can be added via ColormapRegistry.register: mpl.colormaps.register(my_colormap)
register(cmap, *, name=None, force=False)[source]
Register a new colormap. The colormap name can then be used as a string argument to any cmap parameter in Matplotlib. It is also available in pyplot.get_cmap. The colormap registry stores a copy of the given colormap, so that future changes to the original colormap instance do not affect the registered colormap. Think of this as the registry taking a snapshot of the colormap at registration. Parameters
cmapmatplotlib.colors.Colormap
The colormap to register.
namestr, optional
The name for the colormap. If not given, cmap.name is used. force: bool, default: False
If False, a ValueError is raised if trying to overwrite an already registered name. True supports overwriting registered colormaps other than the builtin colormaps.
classmatplotlib.cm.ScalarMappable(norm=None, cmap=None)[source]
Bases: object A mixin class to map scalar data to RGBA. The ScalarMappable applies data normalization before returning RGBA colors from the given colormap. Parameters
normmatplotlib.colors.Normalize (or subclass thereof)
The normalizing object which scales data, typically into the interval [0, 1]. If None, norm defaults to a colors.Normalize object which initializes its scaling based on the first data processed.
cmapstr or Colormap
The colormap used to map normalized data values to RGBA colors. autoscale()[source]
Autoscale the scalar limits on the norm instance using the current array
autoscale_None()[source]
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
propertycallbacksSM[source]
changed()[source]
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
colorbar
The last colorbar associated with this ScalarMappable. May be None.
get_alpha()[source]
Returns
float
Always returns 1.
get_array()[source]
Return the array of values, that are mapped to colors. The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.
get_clim()[source]
Return the values (min, max) that are mapped to the colormap limits.
get_cmap()[source]
Return the Colormap instance.
propertynorm
set_array(A)[source]
Set the value array from array-like A. Parameters
Aarray-like or None
The values that are mapped to colors. The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.
set_clim(vmin=None, vmax=None)[source]
Set the norm limits for image scaling. Parameters
vmin, vmaxfloat
The limits. The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
set_cmap(cmap)[source]
Set the colormap for luminance data. Parameters
cmapColormap or str or None
set_norm(norm)[source]
Set the normalization instance. Parameters
normNormalize or None
Notes If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
to_rgba(x, alpha=None, bytes=False, norm=True)[source]
Return a normalized rgba array corresponding to x. In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable. There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4. In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range. If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1).
matplotlib.cm.get_cmap(name=None, lut=None)[source]
Get a colormap instance, defaulting to rc values if name is None. Colormaps added with register_cmap() take precedence over built-in colormaps. Parameters
namematplotlib.colors.Colormap or str or None, default: None
If a Colormap instance, it will be returned. Otherwise, the name of a colormap known to Matplotlib, which will be resampled by lut. The default, None, means rcParams["image.cmap"] (default: 'viridis').
lutint or None, default: None
If name is not already a Colormap instance and lut is not None, the colormap will be resampled to have lut entries in the lookup table. Notes Currently, this returns the global colormap object, which is deprecated. In Matplotlib 3.5, you will no longer be able to modify the global colormaps in-place.
matplotlib.cm.register_cmap(name=None, cmap=None, *, override_builtin=False)[source]
Add a colormap to the set recognized by get_cmap(). Register a new colormap to be accessed by name LinearSegmentedColormap('swirly', data, lut)
register_cmap(cmap=swirly_cmap)
Parameters
namestr, optional
The name that can be used in get_cmap() or rcParams["image.cmap"] (default: 'viridis') If absent, the name will be the name attribute of the cmap.
cmapmatplotlib.colors.Colormap
Despite being the second argument and having a default value, this is a required argument.
override_builtinbool
Allow built-in colormaps to be overridden by a user-supplied colormap. Please do not use this unless you are sure you need it. Notes Registering a colormap stores a reference to the colormap object which can currently be modified and inadvertently change the global colormap state. This behavior is deprecated and in Matplotlib 3.5 the registered colormap will be immutable.
matplotlib.cm.unregister_cmap(name)[source]
Remove a colormap recognized by get_cmap(). You may not remove built-in colormaps. If the named colormap is not registered, returns with no error, raises if you try to de-register a default colormap. Warning Colormap names are currently a shared namespace that may be used by multiple packages. Use unregister_cmap only if you know you have registered that name before. In particular, do not unregister just in case to clean the name before registering a new colormap. Parameters
namestr
The name of the colormap to be un-registered Returns
ColorMap or None
If the colormap was registered, return it if not return None Raises
ValueError
If you try to de-register a default built-in colormap. | matplotlib.cm_api |
classmatplotlib.cm.ColormapRegistry(cmaps)[source]
Bases: collections.abc.Mapping Container for colormaps that are known to Matplotlib by name. Experimental While we expect the API to be final, we formally mark it as experimental for 3.5 because we want to keep the option to still adapt the API for 3.6 should the need arise. The universal registry instance is matplotlib.colormaps. There should be no need for users to instantiate ColormapRegistry themselves. Read access uses a dict-like interface mapping names to Colormaps: import matplotlib as mpl
cmap = mpl.colormaps['viridis']
Returned Colormaps are copies, so that their modification does not change the global definition of the colormap. Additional colormaps can be added via ColormapRegistry.register: mpl.colormaps.register(my_colormap)
register(cmap, *, name=None, force=False)[source]
Register a new colormap. The colormap name can then be used as a string argument to any cmap parameter in Matplotlib. It is also available in pyplot.get_cmap. The colormap registry stores a copy of the given colormap, so that future changes to the original colormap instance do not affect the registered colormap. Think of this as the registry taking a snapshot of the colormap at registration. Parameters
cmapmatplotlib.colors.Colormap
The colormap to register.
namestr, optional
The name for the colormap. If not given, cmap.name is used. force: bool, default: False
If False, a ValueError is raised if trying to overwrite an already registered name. True supports overwriting registered colormaps other than the builtin colormaps. | matplotlib.cm_api#matplotlib.cm.ColormapRegistry |
register(cmap, *, name=None, force=False)[source]
Register a new colormap. The colormap name can then be used as a string argument to any cmap parameter in Matplotlib. It is also available in pyplot.get_cmap. The colormap registry stores a copy of the given colormap, so that future changes to the original colormap instance do not affect the registered colormap. Think of this as the registry taking a snapshot of the colormap at registration. Parameters
cmapmatplotlib.colors.Colormap
The colormap to register.
namestr, optional
The name for the colormap. If not given, cmap.name is used. force: bool, default: False
If False, a ValueError is raised if trying to overwrite an already registered name. True supports overwriting registered colormaps other than the builtin colormaps. | matplotlib.cm_api#matplotlib.cm.ColormapRegistry.register |
matplotlib.cm.get_cmap(name=None, lut=None)[source]
Get a colormap instance, defaulting to rc values if name is None. Colormaps added with register_cmap() take precedence over built-in colormaps. Parameters
namematplotlib.colors.Colormap or str or None, default: None
If a Colormap instance, it will be returned. Otherwise, the name of a colormap known to Matplotlib, which will be resampled by lut. The default, None, means rcParams["image.cmap"] (default: 'viridis').
lutint or None, default: None
If name is not already a Colormap instance and lut is not None, the colormap will be resampled to have lut entries in the lookup table. Notes Currently, this returns the global colormap object, which is deprecated. In Matplotlib 3.5, you will no longer be able to modify the global colormaps in-place. | matplotlib.cm_api#matplotlib.cm.get_cmap |
matplotlib.cm.register_cmap(name=None, cmap=None, *, override_builtin=False)[source]
Add a colormap to the set recognized by get_cmap(). Register a new colormap to be accessed by name LinearSegmentedColormap('swirly', data, lut)
register_cmap(cmap=swirly_cmap)
Parameters
namestr, optional
The name that can be used in get_cmap() or rcParams["image.cmap"] (default: 'viridis') If absent, the name will be the name attribute of the cmap.
cmapmatplotlib.colors.Colormap
Despite being the second argument and having a default value, this is a required argument.
override_builtinbool
Allow built-in colormaps to be overridden by a user-supplied colormap. Please do not use this unless you are sure you need it. Notes Registering a colormap stores a reference to the colormap object which can currently be modified and inadvertently change the global colormap state. This behavior is deprecated and in Matplotlib 3.5 the registered colormap will be immutable. | matplotlib.cm_api#matplotlib.cm.register_cmap |
classmatplotlib.cm.ScalarMappable(norm=None, cmap=None)[source]
Bases: object A mixin class to map scalar data to RGBA. The ScalarMappable applies data normalization before returning RGBA colors from the given colormap. Parameters
normmatplotlib.colors.Normalize (or subclass thereof)
The normalizing object which scales data, typically into the interval [0, 1]. If None, norm defaults to a colors.Normalize object which initializes its scaling based on the first data processed.
cmapstr or Colormap
The colormap used to map normalized data values to RGBA colors. autoscale()[source]
Autoscale the scalar limits on the norm instance using the current array
autoscale_None()[source]
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None
propertycallbacksSM[source]
changed()[source]
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal.
colorbar
The last colorbar associated with this ScalarMappable. May be None.
get_alpha()[source]
Returns
float
Always returns 1.
get_array()[source]
Return the array of values, that are mapped to colors. The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array.
get_clim()[source]
Return the values (min, max) that are mapped to the colormap limits.
get_cmap()[source]
Return the Colormap instance.
propertynorm
set_array(A)[source]
Set the value array from array-like A. Parameters
Aarray-like or None
The values that are mapped to colors. The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the value array A.
set_clim(vmin=None, vmax=None)[source]
Set the norm limits for image scaling. Parameters
vmin, vmaxfloat
The limits. The limits may also be passed as a tuple (vmin, vmax) as a single positional argument.
set_cmap(cmap)[source]
Set the colormap for luminance data. Parameters
cmapColormap or str or None
set_norm(norm)[source]
Set the normalization instance. Parameters
normNormalize or None
Notes If there are any colorbars using the mappable for this norm, setting the norm of the mappable will reset the norm, locator, and formatters on the colorbar to default.
to_rgba(x, alpha=None, bytes=False, norm=True)[source]
Return a normalized rgba array corresponding to x. In the normal case, x is a 1D or 2D sequence of scalars, and the corresponding ndarray of rgba values will be returned, based on the norm and colormap set for this ScalarMappable. There is one special case, for handling images that are already rgb or rgba, such as might have been read from an image file. If x is an ndarray with 3 dimensions, and the last dimension is either 3 or 4, then it will be treated as an rgb or rgba array, and no mapping will be done. The array can be uint8, or it can be floating point with values in the 0-1 range; otherwise a ValueError will be raised. If it is a masked array, the mask will be ignored. If the last dimension is 3, the alpha kwarg (defaulting to 1) will be used to fill in the transparency. If the last dimension is 4, the alpha kwarg is ignored; it does not replace the pre-existing alpha. A ValueError will be raised if the third dimension is other than 3 or 4. In either case, if bytes is False (default), the rgba array will be floats in the 0-1 range; if it is True, the returned rgba array will be uint8 in the 0 to 255 range. If norm is False, no normalization of the input data is performed, and it is assumed to be in the range (0-1). | matplotlib.cm_api#matplotlib.cm.ScalarMappable |
autoscale()[source]
Autoscale the scalar limits on the norm instance using the current array | matplotlib.cm_api#matplotlib.cm.ScalarMappable.autoscale |
autoscale_None()[source]
Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None | matplotlib.cm_api#matplotlib.cm.ScalarMappable.autoscale_None |
changed()[source]
Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal. | matplotlib.cm_api#matplotlib.cm.ScalarMappable.changed |
colorbar
The last colorbar associated with this ScalarMappable. May be None. | matplotlib.cm_api#matplotlib.cm.ScalarMappable.colorbar |
get_alpha()[source]
Returns
float
Always returns 1. | matplotlib.cm_api#matplotlib.cm.ScalarMappable.get_alpha |
get_array()[source]
Return the array of values, that are mapped to colors. The base class ScalarMappable does not make any assumptions on the dimensionality and shape of the array. | matplotlib.cm_api#matplotlib.cm.ScalarMappable.get_array |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.