About 136,000 results
Open links in new tab
  1. How to Draw Rectangles in Matplotlib (With Examples) - Statology

    Nov 10, 2020 · To draw a rectangle in Matplotlib, you can use the matplotlib.patches.Rectangle function, which uses the following syntax: matplotlib.patches.Rectangle (xy, width, height, angle=0.0) where: xy: The (x, y) coordinates for the anchor point of the rectangle width: Rectangle width height: Rectangle height

  2. matplotlib.patches.Rectangle — Matplotlib 3.10.1 documentation

    A rectangle defined via an anchor point xy and its width and height. The rectangle extends from xy[0] to xy[0] + width in x-direction and from xy[1] to xy[1] + height in y-direction.

  3. python - How to draw a rectangle on image - Stack Overflow

    If you want to change the image data (e.g. draw a rectangle on an image), you could use PIL's ImageDraw, OpenCV, or something similar. Here is PIL's ImageDraw method to draw a rectangle.

  4. 4 Ways to Draw a Rectangle in Matplotlib - Python Pool

    Feb 10, 2021 · To draw rectangles on the matplotlib plot, we use the function matplotlib patches Rectangle. This helps to plot the rectangular patch with a specific width and height.

  5. numpy - Mathematical rectangle function Python - Stack Overflow

    Mar 10, 2017 · I want to make convolution of gaussian and rectangular functions like that: from numpy import linspace, sqrt, sin, exp, convolve, abs from matplotlib import pyplot as plt def gauss(x, x0=0, sigma=1): return exp(-1*(x-x0)**2/(2*sigma**2)) def rect(x): return 1 if abs(x)<=0.5 else 0 x = linspace(-10, 10, 100) f1 = gauss(x, sigma=1) f2 = rect(x)

  6. python - How to draw a rectangle over a specific region in a …

    Oct 22, 2012 · So any rectangle stretching left of 0 or right of 1 is simply drawn off-plot. An easy alternative might be to add a Rectangle to your axis (e.g., via plt.gca and add_patch); Rectangle uses data units for both dimensions. The following would add a grey rectangle with width & height of 1 centered on (2,3):

  7. matplotlib.patches.Rectangle in Python - GeeksforGeeks

    Apr 27, 2020 · The matplotlib.patches.Rectangle class is used to rectangle patch to a plot with lower left at xy = (x, y) with specified width, height and rotation angle. Syntax: class matplotlib.patches.Rectangle (xy, width, height, angle=0.0, **kwargs)

  8. How To Draw a Rectangle on a Plot in Matplotlib?

    Jan 30, 2021 · In this post, we will learn how to add rectangle on top of a plot made with matplotlib in Python. We will first add a simple rectangle with specific color and then learn how to fill the rectangle with a color of choice. Next we will also see an example of adding text to describe the addition of rectangle.

  9. How to Properly Draw Rectangles in Matplotlib and Python

    Dec 18, 2023 · In this Matplotlib and Python tutorial, we thoroughly explain how to draw rectangles in Python and how to adjust the rectangle properties, such as transparency, face color, edge color, hatch, and other visual properties.

  10. Pyplot tutorial — Matplotlib 3.10.1 documentation

    matplotlib.pyplot is a collection of functions that make matplotlib work like MATLAB. Each pyplot function makes some change to a figure: e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc.

Refresh