'Python : Add point to the plot on every user input [duplicate]
I have a created a circle using the matplotlib library. Now in an infinite loop on every user input of x and y, I want to plot the point on the graph. How can I do this withour replotting everything again on user input?
This is what I have tried but this is not working
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['toolbar'] = 'None'
fig = plt.figure()
angle = np.linspace( 0 , 2 * np.pi , 1500 )
radius = 5
figure, axes = plt.subplots( 1 )
plt.title( 'Ring' )
plt.box(False)
plt.axis('off')
while True:
x = radius * np.cos( angle )
y = radius * np.sin( angle )
axes.plot( x, y )
axes.set_aspect( 1 )
# this is the part which I need to update without actually replotting my plot again
i_line = input("Enter the points ").split()
i_x, i_y = int(i_line[0]), int(i_line[1])
plt.scatter(i_x, i_y, color='red')
plt.show()
Solution 1:[1]
You can do it with conditional aggregation:
SELECT customer_id,
SUM(CASE WHEN blocked IS NULL AND unapproved IS NULL THEN cost ELSE 0 END) total
FROM tablename
GROUP BY customer_id;
Or:
SELECT customer_id,
SUM(CASE WHEN COALESCE(locked, unapproved) IS NULL THEN cost ELSE 0 END) total
FROM tablename
GROUP BY customer_id;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | forpas |
