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

+14

# 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. https://ibb.co/9bLqffk 2. https://ibb.co/6YctRSW 3. https://ibb.co/9q2pds6 Here's my try for 1st and 3rd links :- https://code.sololearn.com/cZFvxrTiQ1Q5/?ref=app https://code.sololearn.com/cPSIs2jvznEz/?ref=app

+9

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!

+8

This plots the points https://code.sololearn.com/crmeI2OXX8Ek/?ref=app

+5

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 https://code.sololearn.com/cru5lYl36XKx/?ref=app

+4

♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤ 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

+4

Modified the code ,works fine now

+4

♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤ Use numpy for that! This might help you ig 🤔 https://code.sololearn.com/cc9zfhoR8Lin/?ref=app

+3

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

+3

Namit Jain How can I plot it on graph ?