OwlCyberSecurity - MANAGER
Edit File: plot_directive.cpython-38.pyc
U ��]�i � @ s d Z ddlZddlmZ ddlZddlZddlmZ ddlm Z ddl Z ddlZddlZddl Z ddlZddlZddlmZmZ ddlmZ ddlZddlZddlmZ z2ejd d �� e�de� e�d� W 5 Q R X W n, ek �r ddlmZ e� d� Y nX ddlmZ dd lm!Z!m"Z" ej#Z#dZ$e"j%ddd�dd� �Z&dd� Z'dd� Z(dd� Z)dd� Z*dd� Z+G dd� de�Z,dd � Z-d!d"� Z.d#d$� Z/d%d&� Z0d'd(� Z1d)Z2d*Z3e4� Z5G d+d,� d,e6�Z7d-d.� Z8G d/d0� d0e9�Z:d<d1d2�Z;d=d3d4�Z<d5d6� Z=d>d8d9�Z>d:d;� Z?dS )?a� A directive for including a matplotlib plot in a Sphinx document. By default, in HTML output, `plot` will include a .png file with a link to a high-res .png and .pdf. In LaTeX output, it will include a .pdf. The source code for the plot may be included in one of three ways: 1. **A path to a source file** as the argument to the directive:: .. plot:: path/to/plot.py When a path to a source file is given, the content of the directive may optionally contain a caption for the plot:: .. plot:: path/to/plot.py This is the caption for the plot Additionally, one may specify the name of a function to call (with no arguments) immediately after importing the module:: .. plot:: path/to/plot.py plot_function1 2. Included as **inline content** to the directive:: .. plot:: import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np img = mpimg.imread('_static/stinkbug.png') imgplot = plt.imshow(img) 3. Using **doctest** syntax:: .. plot:: A plotting example: >>> import matplotlib.pyplot as plt >>> plt.plot([1,2,3], [4,5,6]) Options ------- The ``plot`` directive supports the following options: format : {'python', 'doctest'} Specify the format of the input include-source : bool Whether to display the source code. The default can be changed using the `plot_include_source` variable in conf.py encoding : str If this source file is in a non-UTF8 or non-ASCII encoding, the encoding must be specified using the `:encoding:` option. The encoding will not be inferred using the ``-*- coding -*-`` metacomment. context : bool or str If provided, the code will be run in the context of all previous plot directives for which the `:context:` option was specified. This only applies to inline code plot directives, not those run from files. If the ``:context: reset`` option is specified, the context is reset for this and future plots, and previous figures are closed prior to running the code. ``:context:close-figs`` keeps the context but closes previous figures before running the code. nofigs : bool If specified, the code block will be run, but no figures will be inserted. This is usually useful with the ``:context:`` option. Additionally, this directive supports all of the options of the `image` directive, except for `target` (since plot will add its own target). These include `alt`, `height`, `width`, `scale`, `align` and `class`. Configuration options --------------------- The plot directive has the following configuration options: plot_include_source Default value for the include-source option plot_html_show_source_link Whether to show a link to the source in HTML. plot_pre_code Code that should be executed before each plot. If not specified or None it will default to a string containing:: import numpy as np from matplotlib import pyplot as plt plot_basedir Base directory, to which ``plot::`` file names are relative to. (If None or empty, file names are relative to the directory where the file containing the directive is.) plot_formats File formats to generate. List of tuples or strings:: [(suffix, dpi), suffix, ...] that determine the file format and the DPI. For entries whose DPI was omitted, sensible defaults are chosen. When passing from the command line through sphinx_build the list should be passed as suffix:dpi,suffix:dpi, .... plot_html_show_formats Whether to show links to the files in HTML. plot_rcparams A dictionary containing any non-standard rcParams that should be applied before each plot. plot_apply_rcparams By default, rcParams are applied when `context` option is not used in a plot directive. This configuration option overrides this behavior and applies rcParams before each plot. plot_working_directory By default, the working directory will be changed to the directory of the example, so the code can get at its data files, if any. Also its path will be added to `sys.path` so it can import any helper modules sitting beside it. This configuration option can be used to specify a central directory (also added to `sys.path`) where data files and helper modules for all code are located. plot_template Provide a customized template for preparing restructured text. � N)�StringIO)�relpath)�Path)� directives� Directive)�Image)�FigureManagerBaseT)�record�errorZAgg)�_pylab_helpers�cbook� �3.1� PlotDirective)Zalternativec C s t ||||||�S )�^Implementation of the ``.. plot::`` directive. See the module docstring for details. )�run) �name� arguments�options�content�linenoZcontent_offsetZ block_text�state� state_machine� r �E/usr/lib/python3/dist-packages/matplotlib/sphinxext/plot_directive.py�plot_directive� s r c C sH | r| � � sdS | � � �� dkr$dS | � � �� dkr8dS td| ��d S )NT)Zno�0ZfalseF)Zyes�1�truez"%s" unknown boolean)�strip�lower� ValueError��argr r r �_option_boolean� s r$ c C s | dkr| S t d��d S )N)N�reset� close-figsz2argument should be None or 'reset' or 'close-figs')r! r"