I have a data frame in pandas and I am plotting a scatter plot between two columns of the data frame,Now I want to transform the origin from (0,0) to say (1300,50) in this scatter plot.I am using Jupyter IPython notebook on ubuntu
1 Answer
You can use xlim and ylim, and provide either a tuple as (lower, upper) or an int as lower limit only:
import pandas as pd
import numpy as np
plt.style.use('ggplot')
df = pd.DataFrame(data={'X': np.random.random(100) * 50 + 100, 'Y': np.random.random(100) * 250 + 500})
which looks like:
X Y
count 100.000000 100.000000
mean 126.183239 622.705947
std 15.766365 77.727067
min 100.574628 501.077603
25% 113.219299 545.146821
50% 125.318034 626.237368
75% 141.960502 694.636261
max 149.745984 749.947933
Use
df.plot.scatter('X', 'Y', xlim=(100, 150), ylim=(500, 750))
