0

I want to define range of x values appeared in plot in python. For example, here is my code:

import matplotlib.pyplot as plt
plt.figure(13)
ax1=plt.subplot(111)
x=[i for i in range(100)]
y=[i**2 for i in x]
ax1.plot(x,y)

However, I want to see in the graph x ranges from 0 to 60 and 80 to 100. How, I can do it in matplot. Actual, problem is more complicated, just removing data doesn't appear to be good solution. I want to change plot.

I tried ax1.set_xlim([0,60]) but want to see from 80 to 100 also.

6
  • 1
    Show us your code and what you have tried. It is important to create a Minimal, Complete, and Verifiable Example. Commented Nov 13, 2017 at 14:53
  • so... where is your code? Commented Nov 13, 2017 at 15:03
  • plt.figure(12) ax1 = plt.subplot(111) for T in Tave[:-2]: GI_d=np.diff(np.array(GI[T][1:])) GV_d=np.diff(np.array(GV[T][1:])) GR_d=list(GI_d/GV_d) plt.plot(GV[T][2:],GR_d,label='T='+str(T)+'K') ax1.set_ylim([-0.1, 0.4]) ax1.set_xlim([-1400,-200]) # want to change this part [-1400,-200] to [200,1400] range plt.legend() plt.show() Commented Nov 13, 2017 at 15:05
  • This is my real code. By idea is to define the range of the x axis . Commented Nov 13, 2017 at 15:09
  • Thanks for comment. minimal example is provided. Commented Nov 13, 2017 at 15:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.