line

Plotting sentiment analysis over time in python

Plotting sentiment analysis over time in python Question: I am trying to plot the results of my sentiment analysis over time. The code involves comments from a forum. An example of my code looks something like this: Timestamp Sentiment 2021-01-28 21:37:41 Positive 2021-01-28 21:32:10 Negative 2021-01-29 21:30:35 Positive 2021-01-29 21:28:57 Neutral 2021-01-29 21:26:56 Negative I …

Total answers: 2

Get a point's position from an angle and the length of the line

Get a point's position from an angle and the length of the line Question: I’m programming a game in Python, with pygame, and I’d like to make a function that draws a line in a specific direction from a point, with a specific length, for example, the definition of the funcion would be: def draw_line(position1: …

Total answers: 3

Matplotlib line width based on axis, not on points

Matplotlib line width based on axis, not on points Question: If you set a line width in Matplotlib, you have to give the line width in points. In my case, I have two circles, both with radius R and I want to connect them with a line. I want this line to be 2*R wide …

Total answers: 3

Distance from a point to a line

Distance from a point to a line Question: I have created a class “Point” and i want to calculate the shortest distance between a given point and a line ( characterized by 2 other points ), all points are known. I tried to use this formula : |Ax+By+C| / sqrt(A^2+B^2) , but i messed up …

Total answers: 4

Pygame draw anti-aliased thick line

Pygame draw anti-aliased thick line Question: I used to draw lines (given some start and end points) at pygame like this: pygame.draw.line(window, color_L1, X0, X1, 2), where 2 was defining the thickness of the line. As, anti-aliasing is not supported by .draw, so I moved to .gfxdraw and pygame.gfxdraw.line(window, X0[0], X0[1], X1[0], X1[1], color_L1). However, …

Total answers: 6

Infinite horizontal line in Bokeh

Infinite horizontal line in Bokeh Question: Is there a way to plot an infinite horizontal line with Bokeh? The endpoints of the line should never become visible, no matter how far out the user is zooming. This is what I’ve tried so far. It just prints an empty canvas: import bokeh.plotting as bk import numpy …

Total answers: 4

Matplotlib: Plotting numerous disconnected line segments with different colors

Matplotlib: Plotting numerous disconnected line segments with different colors Question: I have a set of data records like this: (s1, t1), (u1, v1), color1 (s2, t2), (u2, v2), color2 . . . (sN, tN), (uN, vN), colorN In any record, the first two values are the end-points of a line segment, the third value is …

Total answers: 4

How do I compute the intersection point of two lines?

How do I compute the intersection point of two lines? Question: I have two lines that intersect at a point. I know the endpoints of the two lines. How do I compute the intersection point in Python? # Given these endpoints #line 1 A = [X, Y] B = [X, Y] #line 2 C = …

Total answers: 10

Why doesn't .rstrip('n') work?

Why doesn't .rstrip('n') work? Question: Let’s say doc.txt contains a b c d and that my code is f = open(‘doc.txt’) doc = f.read() doc = doc.rstrip(‘n’) print doc why do I get the same values? Asked By: Deneb || Source Answers: rstrip strips trailing spaces from the whole string. If you were expecting it …

Total answers: 6

matplotlib 2d line line,=plot comma meaning

matplotlib 2d line line,=plot comma meaning Question: I’m walking through basic tutorials for matplotlib, and the example code that I’m working on is: import numpy as np import matplotlib.pylab as plt x=[1,2,3,4] y=[5,6,7,8] line, = plt.plot(x,y,’-‘) plt.show() Does anyone know what the comma after line (line,=plt.plot(x,y,’-‘)) means? I thought it was a typo but obviously …

Total answers: 4