1

I'm simply asking how I would go about changing my x axis. I've been having trouble finding an answer online that worked with my current setup.

This is my plotting code:

import scipy.io as spio
import numpy as np
import csv
import pandas as pd
import matplotlib as plt


onfile='file'

s=spio.readsav(onfile,python_dict=True,verbose=True)

a=np.asarray(s['a'])
b=np.asarray(s['b'])
c=np.asarray(s['c'])
d=np.asarray(s['d'])


df = pd.DataFrame({'a':a,'b':b,'c':c,'d':d})
df.plot(x='a',y=['b','c','d'],kind='line')

I'm trying to plot within the "x" axis of 50-60

2
  • 1
    First, ax=df.plot... then ax.set_xlim(50,60). Commented Aug 23, 2018 at 17:51
  • @ anishtain4, I appreciate the tough love. Helped me solve it the way I should have in the first place. Commented Aug 23, 2018 at 18:17

2 Answers 2

2

Use axes.set_xlim:

ax = df.plot(x='a',y=['b','c','d'],kind='line')
ax.set_xlim(50,60)
Sign up to request clarification or add additional context in comments.

Comments

0

Ended up looking at the matplotlib.pyplot documentation. solution ended up being:

x=a
y=b
plt.axis(xmin=50, xmax=60, ymin = -200, ymax = 200)
plt.scatter(x,y)

Thanks for all of the help!

Comments

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.