0

I am trying to make a scatter plot showing the housing prices in Manhattan using the longitude and latitude from a data set. When creating the scatter plot. The output only shows the extreme values of the longitude although all the other values are grouped in the range -74 to -72 (longitude). I don't know how to set the specific range in the x axis so the longitudes represented show the relevant data from the data set.

x = dataset_noise['Lon']
y = dataset_noise['Lat']


no_of_values = len(dataset_noise['Lon'])
index = np.arange(no_of_values)

plt.figure(figsize=(6,6))
plt.scatter(x, y, cmap=plt.get_cmap("jet"),linewidths=0.5,marker='.',alpha=0.2,label='Prices')

plt.title('House prices in Manhattan') 
plt.show()

This is what I coded and the output

enter image description here

vyi
  • 1,078
  • 1
  • 19
  • 46
  • 1
    Does this help? https://stackoverflow.com/questions/3777861/how-to-set-the-y-axis-limit – Nyps Dec 16 '22 at 12:08

1 Answers1

0

You can use the following two functions provided by the mpl :

1. set_xlim
2. set_ylim

these functions accept an interval (a list/tuple argument with lower (L) and upper (U) limits) [L, U] or (L, U)

vyi
  • 1,078
  • 1
  • 19
  • 46