How do I plot these points on graph ? 😌😌 | Sololearn: Learn to code for FREE!


How do I plot these points on graph ? 😌😌

I want to plot given points on my made graph (refer 2nd link) But I can only make graph having x-axis & y-axis (refer 1st link) And I am also able to plot a single point (refer 3rd link) Please help me how can I plot many points from the Input given by user on this graph 1. 2. 3. Here's my try for 1st and 3rd links :-

9/7/2020 2:20:33 PM

Prince Kumar

9 Answers

New Answer


You can use matplotlib 🙌 But for that you will require x-coordinates and y-coordinates of all the points that will be i and j respectively!


This plots the points


Depending on the coordinate system you use, I always use the right hand rule.. +x increases toward the right and +y increases down the bottom( yes , that's not how it is in math but transforming the system is simple, you can just replace sin with cos, and cos with sin for every point). However to get the quadrant for a given vector x, y.. You just need to take the tangent of the position, tan(y/x) but this can lead to a bug if the quadrant's angle is negative, so I used the builtin atan2 instead for perfect answer


♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤ If the origin lies on [10,10] So, for a point [x,y] => in your code x = j and y = i If x > 10 and y < 10: VI Quadrant If x < 10 and y > 10: III Quadrant If x < 10 and y < 10: II Quadrant If x > 10 and y < 10: I Quadrant


Modified the code ,works fine now


♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤ Use numpy for that! This might help you ig 🤔


Abhay Thanks for answering me, but I don't want to write conditions many times in if part for each points Suppose I have 10 points which lie on different quadrants, I want that there should be a function which will check in which quadrant the given point lie & according to that it will plot it on graph


Namit Jain How can I plot it on graph ?


P po