0

I am working on drawing lineplots with matplotlib.

I checked several posts and could understand how the line break works on matplotlib (Break // in x axis of matplotlib)

However, I was wondering is it possible to break x and y axis all together at the same time.

My current drawing looks like below.

enter image description here

As shown on the graph, x-axis [2000,5000] waste spaces a lot.

Because I have more data that need to be drawn after 7000, I want to save more space.

Is it possible to split x-axis together with y-axis?

Or is there another convenient way to not to show specific region on lineplot?

If there is another library enabling this, I am willing to drop matplotlib and adopt others...

ruach
  • 1,369
  • 11
  • 21

1 Answers1

0

Maybe splitting the axis isn't your best choice. I would perhaps try inserting another smaller figure into the open space of your large figure using add_axes(). Here is a small example.

t = np.linspace(0, 5000, 1000) # create 1000 time stamps
data = 5*t*np.exp(-t/100) # and some fake data

fig, ax = plt.subplots()
ax.plot(t, data)

box = ax.get_position()
width = box.width*0.6
height = box.height*0.6
x = 0.35
y = 0.35
subax = fig.add_axes([x,y,width,height])

subax.plot(t, data)
subax.axis([0, np.max(t)/10, 0, np.max(data)*1.1])

plt.show()

Putting an axis within an axis using add_axis()