logo
down
shadow

How to fill a rectangle drawn on top of a bar chart (Tkinter Python)


How to fill a rectangle drawn on top of a bar chart (Tkinter Python)

By : user2185052
Date : November 20 2020, 04:01 AM
Hope that helps Instead of plotting lines to draw the rectangle you can use a rectangle patch:
Put
code :
    rect = Rectangle((-1, -1), 14, 2, color='orange', fill=True, alpha=0.5)
    self.a.add_artist(rect)
    self.a.plot([-1, 13], [1, 1], color = 'orange')
    self.a.plot([13, 13], [1, -1], color = 'orange')
    self.a.plot([13, -1], [-1, -1], color = 'orange')
    self.a.plot([-1, -1], [-1, 1], color = 'orange')


Share : facebook icon twitter icon
Tkinter: getting coordinates of a mouse drawn rectangle

Tkinter: getting coordinates of a mouse drawn rectangle


By : Luberto
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You can use canvas.bbox(item) to get the coordinates of the bounding box of an item on the canvas. Because your item is a rectangle, the bounding box exactly represents the rectangle.
In your case it would be:
code :
self.canvas.bbox(self.rect)
Upper left  = x0, y0
Upper right = x1, y0
Lower left  = x0, y1
Lower right = x1, y1

width  = x1-x0
height = y1-y0
Getting the fill color or any other property of a item drawn in a canvas in tkinter(Python)

Getting the fill color or any other property of a item drawn in a canvas in tkinter(Python)


By : Ervin Riddick
Date : March 29 2020, 07:55 AM
wish helps you you can do this using the itemcget method:
effbot
code :
color = self.canvas_1.itemcget(i, "fill")
Setting the fill of a rectangle drawn with canvas to an RGB value

Setting the fill of a rectangle drawn with canvas to an RGB value


By : LittleG
Date : March 29 2020, 07:55 AM
it should still fix some issue You are getting an "unknown color name" error. You have to either use the name from the list of colors or use hexadecimal format: #RRGGBB
To convert a tuple of integer values to RGB format use this:
code :
colorval = "#%02x%02x%02x" % (109, 170, 44)
Unable to apply fill for path drawn rectangle

Unable to apply fill for path drawn rectangle


By : amos
Date : March 29 2020, 07:55 AM
wish helps you The problem appears to be that you aren't creating a closed shape, you are just creating a series of lines that don't form a shape.
This is a closed path. If you took a pencil and drew the points, you'd see that it would be closed.
code :
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');

ctx.fillStyle = "#F00"; // red
ctx.strokeStyle = "#0F0"; // green

ctx.beginPath();
ctx.moveTo(50, 50);
ctx.lineTo(100, 50);
ctx.lineTo(100, 100);
ctx.lineTo(50, 100);
ctx.closePath();

ctx.fill();
ctx.stroke();
canvas {
 border: 1px solid #000;
}
<canvas />
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');

ctx.fillStyle = "#F00"; // red
ctx.strokeStyle = "#0F0"; // green

ctx.beginPath();
ctx.moveTo(50, 50);
ctx.lineTo(100, 50);

ctx.moveTo(100, 50);
ctx.lineTo(100, 100);

ctx.moveTo(100, 100);
ctx.lineTo(50, 100);

ctx.moveTo(50, 100);
ctx.lineTo(50, 50);

ctx.closePath();

ctx.fill();
ctx.stroke();
canvas {
 border: 1px solid #000;
}
<canvas />
Using image with rectangle drawn over it in python

Using image with rectangle drawn over it in python


By : Sean K
Date : March 29 2020, 07:55 AM
it fixes the issue Heh, several years late to help the original poster, but I just hit this problem myself and didn't have control over the image source (so cv2.imread wasn't a great solution for me - I'd've had to have written the image back to disk first).
I was able to proceed with image = image.copy().
Related Posts Related Posts :
  • Creating a Dataframe of Proportions
  • Scrapy with dynamic captcha
  • In python, how do I get urllib to recognize multiple lines in a string as separate URLs?
  • Add prefix and suffix to each element of a nested list
  • Generate string set from csv file in Python
  • Custom usage message for many-valued argument
  • Python Class, how to skip a wrong entry and proceed to next entry
  • Numpy efficient way to parse array of string
  • Kivy , Python: Update Label on_file_drop
  • What does it mean if a deeper conv layer converges first?
  • Selecting User in client.send_message() from arg list
  • python slicing multi levels list of dict using list comprehension
  • Value Error problem with multicell Dimensions must be equal, but are 20 and 13
  • How to print a board with coordinates?
  • Keras LSTM shape doesn't contain length of sequence
  • Boxplot with Pandas in Python
  • How can I rename a PySpark dataframe column by index? (handle duplicated column names)
  • How to calculate hash of a python class object
  • Using ideas from HashEmbeddings with sklearn's HashingVectorizer
  • keycloak.exceptions.KeycloakGetError: 404: b'' using Python 3.7
  • How to modify a column in a SQLite3?
  • VS Integration Services: flat file source to OLE DB destination - detect new data columns in file, add columns to table,
  • Customize xticks in matplotlib plot
  • How can I show the image in a labelframe which is inserted through askopenfilename?
  • Boxplot with distibution size histogram on top (and median regression)
  • Fit differential equation with scipy
  • ModuleNotFoundError: Correct setup
  • How to pass rendered plot to a html file through render_template?
  • Create flat ndarray from DataFrame column containing arrays
  • Bring radial axes labels in front of lines of polar plot matplotlib
  • Python3: Unable to split word from parsed data
  • Using Python to login to a website and web scrape
  • Customise shift in matplotlib offset
  • Combining and Reshaping rows and columns of 2 dataframes in R or Python
  • Regex condition after and before a known phrase
  • subplots based on records of two different pandas DataFrames ( with same structure) using Seaborn or Matplotlib
  • find numpy array in other numpy array
  • Print Triangle Pyramid pattern using for loop python
  • Python Script Running through Command Line Not Creating CSV
  • Questions about Subclassing
  • Creating list with dictionary instead of multiple dictionaries in python
  • Sorting queryset results in a template
  • Django Rest Framework allow not authenticated access to a view in certain cases
  • How do I efficiently map integers to URIs in a multidemnsional array?
  • Installing Python packages for Visual Studio Code
  • How to merge two columns into one in pandas dataframe
  • Decompose string of different symbols in python
  • pandas merge and group concat
  • How to traverse tree for making binary code from a HuffmanTree?
  • Check if IP is in network on Python3
  • non equally spaced points along x-axis in a plot
  • Concatenation of text files consisting list of lists?
  • Use regex to parse characters on a line of text
  • pandas df.fillna - filling NaNs after outer join with correct values
  • How can I undo a time series conversion of a pandas dataframe?
  • Virtual environment is not working in Django
  • FileNotFoundError in Python during Arabic text analysis
  • How to read email using python and smtplib
  • How to write a function which takes a string and turns into a single digit?
  • Linear Regression without Least Squares in sklearn
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org