:py:mod:`symfem.plotting` ========================= .. py:module:: symfem.plotting .. autoapi-nested-parse:: Plotting. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: symfem.plotting.Colors symfem.plotting.PictureElement symfem.plotting.Line symfem.plotting.Bezier symfem.plotting.Arrow symfem.plotting.NCircle symfem.plotting.Fill symfem.plotting.Math symfem.plotting.Picture Functions ~~~~~~~~~ .. autoapisummary:: symfem.plotting.tex_font_size Attributes ~~~~~~~~~~ .. autoapisummary:: symfem.plotting.PointOrFunction symfem.plotting.SetOfPointsOrFunctions symfem.plotting.colors .. py:data:: PointOrFunction .. py:data:: SetOfPointsOrFunctions .. py:function:: tex_font_size(n: int) Convert a font size to a TeX size command. :param n: Font size :returns: TeX size command .. py:class:: Colors Class storing colours used in diagrams. .. py:attribute:: BLACK :value: '#000000' .. py:attribute:: WHITE :value: '#FFFFFF' .. py:attribute:: ORANGE :value: '#FF8800' .. py:attribute:: BLUE :value: '#44AAFF' .. py:attribute:: GREEN :value: '#55FF00' .. py:attribute:: PURPLE :value: '#DD2299' .. py:attribute:: GRAY :value: '#AAAAAA' .. py:method:: entity(n: int) -> str Get the color used for an entity of a given dimension. :param n: The dimension of the entity :returns: The color used for entities of the given dimension .. py:method:: get_tikz_name(name: str) -> str Get the name of the colour to be used in Tikz. :param name: HTML name of the color :returns: The Tikz name of the color .. py:method:: get_tikz_definitions() -> str Get the definitions of colours used in Tikz. :returns: Definitions of Tikz colors .. py:data:: colors .. py:class:: PictureElement Bases: :py:obj:`abc.ABC` An element in a picture. .. py:property:: points :type: symfem.geometry.SetOfPoints :abstractmethod: Get set of points used by this element. :returns: A set of points .. py:method:: as_svg(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str :abstractmethod: Return SVG format. :param map_pt: A function that adjust the origin and scales the picture :returns: An SVG string .. py:method:: as_tikz(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str :abstractmethod: Return Tikz format. :param map_pt: A function that adjust the origin and scales the picture :returns: A Tikz string .. py:method:: minx() -> sympy.core.expr.Expr Get the minimum x-coordinate. :returns: The minimum x-coordinate .. py:method:: miny() -> sympy.core.expr.Expr Get the minimum y-coordinate. :returns: The minimum y-coordinate .. py:method:: maxx() -> sympy.core.expr.Expr Get the maximum x-coordinate. :returns: The maximum x-coordinate .. py:method:: maxy() -> sympy.core.expr.Expr Get the maximum y-coordinate. :returns: The maximum y-coordinate .. py:class:: Line(start: symfem.geometry.PointType, end: symfem.geometry.PointType, color: str, width: float) Bases: :py:obj:`PictureElement` A line. .. py:property:: points :type: symfem.geometry.SetOfPoints Get set of points used by this element. :returns: A set of points .. py:method:: as_svg(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return SVG format. :param map_pt: A function that adjust the origin and scales the picture :returns: An SVG string .. py:method:: as_tikz(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return Tikz format. :param map_pt: A function that adjust the origin and scales the picture :returns: A Tikz string .. py:class:: Bezier(start: symfem.geometry.PointType, mid1: symfem.geometry.PointType, mid2: symfem.geometry.PointType, end: symfem.geometry.PointType, color: str, width: float) Bases: :py:obj:`PictureElement` A Bezier curve. .. py:property:: points :type: symfem.geometry.SetOfPoints Get set of points used by this element. :returns: A set of points .. py:method:: as_svg(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return SVG format. :param map_pt: A function that adjust the origin and scales the picture :returns: An SVG string .. py:method:: as_tikz(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return Tikz format. :param map_pt: A function that adjust the origin and scales the picture :returns: A Tikz string .. py:class:: Arrow(start: symfem.geometry.PointType, end: symfem.geometry.PointType, color: str, width: float) Bases: :py:obj:`PictureElement` An arrow. .. py:property:: points :type: symfem.geometry.SetOfPoints Get set of points used by this element. :returns: A set of points .. py:method:: as_svg(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return SVG format. :param map_pt: A function that adjust the origin and scales the picture :returns: An SVG string .. py:method:: as_tikz(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return Tikz format. :param map_pt: A function that adjust the origin and scales the picture :returns: A Tikz string .. py:class:: NCircle(centre: symfem.geometry.PointType, number: int, color: str, text_color: str, fill_color: str, radius: float, font_size: Union[int, None], width: float, font: str) Bases: :py:obj:`PictureElement` A circle containing a number. .. py:property:: points :type: symfem.geometry.SetOfPoints Get set of points used by this element. :returns: A set of points .. py:method:: as_svg(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return SVG format. :param map_pt: A function that adjust the origin and scales the picture :returns: An SVG string .. py:method:: as_tikz(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return Tikz format. :param map_pt: A function that adjust the origin and scales the picture :returns: A Tikz string .. py:class:: Fill(vertices: symfem.geometry.SetOfPoints, color: str, opacity: float) Bases: :py:obj:`PictureElement` A filled polygon. .. py:property:: points :type: symfem.geometry.SetOfPoints Get set of points used by this element. :returns: A set of points .. py:method:: as_svg(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return SVG format. :param map_pt: A function that adjust the origin and scales the picture :returns: An SVG string .. py:method:: as_tikz(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return Tikz format. :param map_pt: A function that adjust the origin and scales the picture :returns: A Tikz string .. py:class:: Math(point: symfem.geometry.PointType, math: str, color: str, font_size: int, anchor: str) Bases: :py:obj:`PictureElement` A mathematical symbol. .. py:property:: points :type: symfem.geometry.SetOfPoints Get set of points used by this element. :returns: A set of points .. py:method:: as_svg(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return SVG format. :param map_pt: A function that adjust the origin and scales the picture :returns: An SVG string .. py:method:: as_tikz(map_pt: Callable[[symfem.geometry.PointType], Tuple[float, float]]) -> str Return Tikz format. :param map_pt: A function that adjust the origin and scales the picture :returns: A Tikz string .. py:class:: Picture(padding: sympy.core.expr.Expr = sympy.Integer(25), scale: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, axes_3d: Optional[symfem.geometry.SetOfPointsInput] = None, dof_arrow_size: Union[int, sympy.core.expr.Expr] = 1, title: Optional[str] = None, desc: Optional[str] = None, svg_metadata: Optional[str] = None, tex_comment: Optional[str] = None) A picture. .. py:attribute:: axes_3d :type: symfem.geometry.SetOfPoints .. py:method:: z(p_in: PointOrFunction) -> sympy.core.expr.Expr Get the into/out-of-the-page component of a point. :param p_in: The point :returns: The into/out-of-the-page component of the point .. py:method:: to_2d(p: symfem.geometry.PointType) -> symfem.geometry.PointType Map a point to 2D. :param p: The point :returns: The projection of the point into 2 dimensions .. py:method:: parse_point(p: PointOrFunction) -> symfem.geometry.PointType Parse an input point. :param p: a point or a function :returns: The point as a tuple of Sympy expressions .. py:method:: add_line(start: PointOrFunction, end: PointOrFunction, color: str = colors.BLACK, width: float = 4.0) Add a line to the picture. :param start: The start point of the line :param end: The end point of the line :param color: The color of the line :param width: The width of the line .. py:method:: add_bezier(start: PointOrFunction, mid1: PointOrFunction, mid2: PointOrFunction, end: PointOrFunction, color: str = colors.BLACK, width: float = 4.0) Add a Bezier curve to the picture. :param start: The start point of the Bezier curve :param mid1: The first control point :param mid2: The second control point :param end: The end point of the Bezier curve :param color: The color of the Bezier curve :param width: The width of the Bezier curve .. py:method:: add_arrow(start: PointOrFunction, end: PointOrFunction, color: str = colors.BLACK, width: float = 4.0) Add an arrow to the picture. :param start: The start point of the arrow :param end: The end point of the arrow :param color: The color of the arrow :param width: The width of the arrow .. py:method:: add_dof_marker(point: PointOrFunction, number: int, color: str, bold: bool = True) Add a DOF marker. :param point: The point :param number: The number to put in the marker :param color: The color of the marker :param bold: Should the marker be bold? .. py:method:: add_dof_arrow(point: PointOrFunction, direction: PointOrFunction, number: int, color: str = colors.PURPLE, shifted: bool = False, bold: bool = True) Add a DOF arrow. :param point: The point :param direction: The direction of the arrow :param number: The number to put in the marker :param color: The color of the marker :param shifted: Should the marker be shifted? :param bold: Should the marker be bold? .. py:method:: add_ncircle(centre: PointOrFunction, number: int, color: str = 'red', text_color: str = colors.BLACK, fill_color: str = colors.WHITE, radius: float = 20.0, font_size: Optional[int] = None, width: float = 4.0, font: str = "'Varela Round',sans-serif") Add a numbered circle to the picture. :param centre: The centre points :param number: The number in the circle :param color: The color of the outline :param text_color: The color of the test :param fill_color: The colour of the background fill :param radius: The radius of the circle :param font_size: The font size :param width: The width of the line :param font: The font .. py:method:: add_math(point: symfem.geometry.PointTypeInput, math: str, color: str = colors.BLACK, font_size: int = 35, anchor='center') Create mathematical symbol. :param point: The point to put the math :param math: The math :param color: The color of the math :param font_size: The font size :param anchor: The point on the equation to anchor to .. py:method:: add_fill(vertices: SetOfPointsOrFunctions, color: str = 'red', opacity: float = 1.0) Add a filled polygon to the picture. :param vertices: The vertices of the polygon :param color: The color of the polygon :param opacity: The opacity of the polygon .. py:method:: compute_scale(unit: str = 'px', reverse_y: bool = True) -> Tuple[sympy.core.expr.Expr, sympy.core.expr.Expr, sympy.core.expr.Expr, Callable[[symfem.geometry.PointType], Tuple[float, float]]] Compute the scale and size of the picture. :param unit: The unit to use. Accepted values: px, cm, mm :param reverse_y: Should the y-axis be reversed? :returns: The scale, height, and width of the image, and a mapping function .. py:method:: as_svg(filename: Optional[str] = None) -> str Convert to an SVG. :param filename: The file name :returns: The image as an SVG string .. py:method:: as_png(filename: str, png_scale: Optional[float] = None, png_width: Optional[int] = None, png_height: Optional[int] = None) Convert to a PNG. :param filename: The file name :param png_scale: The scale of the png :param png_width: The width of the png :param png_height: The height of the png .. py:method:: as_tikz(filename: Optional[str] = None) -> str Convert to tikz. :param filename: The file name :returns: The image as a Tikz string .. py:method:: save(filename: Union[str, List[str]], plot_options: Dict[str, Any] = {}) Save the picture as a file. :param filename: The file name :param plot_options: The plotting options