OwlCyberSecurity - MANAGER
Edit File: backend_template.cpython-38.pyc
U ��]$ � @ s� d Z ddlmZ ddlmZmZmZmZ ddlm Z G dd� de�Z G dd� de�Zd d � Zdd�d d�Z e d�dd�Zdd� ZG dd� de�ZG dd� de�ZeZeZdS )a� This is a fully functional do nothing backend to provide a template to backend writers. It is fully functional in that you can select it as a backend with import matplotlib matplotlib.use('Template') and your matplotlib scripts will (should!) run without error, though no output is produced. This provides a nice starting point for backend writers because you can selectively implement methods (draw_rectangle, draw_lines, etc...) and slowly see your figure come to life w/o having to have a full blown implementation before getting any results. Copy this to backend_xxx.py and replace all instances of 'template' with 'xxx'. Then implement the class methods and functions below, and add 'xxx' to the switchyard in matplotlib/backends/__init__.py and 'xxx' to the backends list in the validate_backend method in matplotlib/__init__.py and you're off. You can use your backend with:: import matplotlib matplotlib.use('xxx') import matplotlib.pyplot as plt plt.plot([1,2,3]) plt.show() matplotlib also supports external backends, so you can place you can use any module in your PYTHONPATH with the syntax:: import matplotlib matplotlib.use('module://my_backend') where my_backend.py is your module name. This syntax is also recognized in the rc file and in the -d argument in pylab, e.g.,:: python simple_plot.py -dmodule://my_backend If your backend implements support for saving figures (i.e. has a print_xyz() method) you can register it as the default handler for a given file type from matplotlib.backend_bases import register_backend register_backend('xyz', 'my_backend', 'XYZ File Format') ... plt.savefig("figure.xyz") The files that are most relevant to backend_writers are matplotlib/backends/backend_your_backend.py matplotlib/backend_bases.py matplotlib/backends/__init__.py matplotlib/__init__.py matplotlib/_pylab_helpers.py Naming Conventions * classes Upper or MixedUpperCase * variables lower or lowerUpper * functions lower or underscore_separated � )�Gcf)�FigureCanvasBase�FigureManagerBase�GraphicsContextBase�RendererBase)�Figurec @ s\ e Zd ZdZdd� Zddd�Zdd� Zdd d�Zdd � Zdd� Z dd� Z dd� Zdd� ZdS )�RendererTemplatez� The renderer handles drawing/rendering operations. This is a minimal do-nothing class that can be used to get started when writing a new backend. Refer to backend_bases.RendererBase for documentation of the classes methods. c C s || _ d S �N)�dpi)�selfr � r �F/usr/lib/python3/dist-packages/matplotlib/backends/backend_template.py�__init__O s zRendererTemplate.__init__Nc C s d S r r )r �gc�pathZ transformZrgbFacer r r � draw_pathR s zRendererTemplate.draw_pathc C s d S r r )r r �x�yZimr r r � draw_imagem s zRendererTemplate.draw_imageFc C s d S r r ) r r r r �s�propZangle�ismathZmtextr r r � draw_textp s zRendererTemplate.draw_textc C s dS )NTr �r r r r �flipys s zRendererTemplate.flipyc C s dS )N)�d r r r r r r �get_canvas_width_heightw s z(RendererTemplate.get_canvas_width_heightc C s dS )N)� r r r )r r r r r r r �get_text_width_height_descent{ s z.RendererTemplate.get_text_width_height_descentc C s t � S r )�GraphicsContextTemplater r r r �new_gc~ s zRendererTemplate.new_gcc C s |S r r )r Zpointsr r r �points_to_pixels� s z!RendererTemplate.points_to_pixels)N)FN) �__name__� __module__�__qualname__�__doc__r r r r r r r r r! r r r r r G s r c @ s e Zd ZdZdS )r a� The graphics context provides the color, line styles, etc... See the cairo and postscript backends for examples of mapping the graphics context attributes (cap styles, join styles, line widths, colors) to a particular backend. In cairo this is done by wrapping a cairo.Context object and forwarding the appropriate calls to it using a dictionary mapping styles to gdk constants. In Postscript, all the work is done by the renderer, mapping line styles to postscript calls. If it's more appropriate to do the mapping at the renderer level (as in the postscript backend), you don't need to override any of the GC methods. If it's more appropriate to wrap an instance (as in the cairo backend) and do the mapping here, you'll need to override several of the setter methods. The base GraphicsContext stores colors as a RGB tuple on the unit interval, e.g., (0.5, 0.0, 1.0). You may need to map this to colors appropriate for your backend. N�r"