2

I am trying to plot set of test point VS point being tested with Python. I tried several codes and I couldn't figure it out.

train_pts2 = {
   "N": [(0.125,0.11), (0.375,0.21), (0.625,0.31), (0,0.01), (0.375,0.50), (0.80,0)],
   "Y": [(0.075,0.38), (0.5,0.22), (1,0.41), (0.70,1),(0.325,0.65), (0.70,0.61)],
   "TBD": [(0.70,0.61)]
   }

So the plot will be scatter plot that tells whether pLoan belongs to N or Y

something like

enter image description here

1
  • Did you already have a look at the scatter plots from matplotlib? matplotlib.org Commented Nov 11, 2017 at 23:03

1 Answer 1

1

You can try with the matplotlib library in python with the scatter() function

import numpy as np
import matplotlib.pyplot as plt

train_pts2 = {
   "N": [(0.125,0.11), (0.375,0.21), (0.625,0.31), (0,0.01), (0.375,0.50), (0.80,0)],
   "Y": [(0.075,0.38), (0.5,0.22), (1,0.41), (0.70,1),(0.325,0.65), (0.70,0.61)],
   "TBD": [(0.70,0.61)]
   }

colors = {
    "N" : "orange",
    "Y" : "blue",
    "TBD" : "green"
}

for label in ["N", "Y", "TBD"]:
    x = [item[0] for item in train_pts2[label]]
    y = [item[1] for item in train_pts2[label]]
    plt.scatter(x, y, c=colors[label], label=label)

plt.xlabel("Age of Loan")
plt.ylabel("Loan Amount")
plt.xlim(xmin=0)
plt.ylim(ymin=0)
plt.grid(True)
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
plt.show()

Matplotlib Scatter Example

For more information, you can reach the scatter_demo.py example.

Hope it helps.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, but not close to the plot I provided. also the point pLoan = (0.70,0.61) is not part of the testSet. I am trying to determine point (0.70 , 0.61 ) on the plot but I don't see it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.