0

I have the following code and am really struggling to get the plot on the whole screen.

fig = plt.figure()
fig.subplots_adjust(bottom=0.2)
ax1 = fig.add_subplot(212)
ax1.set_xlabel('Time')
ax1.set_ylim(0,time)
line1 = ax1.plot(a,'bo-',label='One')
line2 = ax1.plot(b,'mo-',label='Two')
lines = line1 + line2
labels = [l.get_label() for l in lines]
ax1.legend(lines, labels, loc=(0,-0.5), ncol=2)
plt.show()

I tried all the answers I found on the web and all the suggestions in the thread Extend python plots to full screen, none of them worked.

Any help would be appreciated!

P.S. I'm not using

t = np.arange(b)
plt.plot(t, a, 'bo-')

for example because it doesn't work if the x and y values are not the same and I cannot predefine x as it varies for my program.

M.V
  • 3
  • 1
  • What do you mean by full screen? Do you want a single sub plot like `ax1 = fig.add_subplot(111)`? – sauerburger Oct 09 '17 at 19:56
  • @sauerburger Yes, that's what I was after!! Thank you for the help! I had come across this example https://pythonprogramming.net/subplot2grid-add_subplot-matplotlib-tutorial/ and was thrown off to believe '212' stands for something completely different... – M.V Oct 09 '17 at 21:44

1 Answers1

0

The line

ax1 = fig.add_subplot(212)

creates a 2x1 plot and returns the second sub-plot. If you want a single plot, change this line to

ax1 = fig.add_subplot(111)

i.e 1x1 split returning the single sub-plot.

sauerburger
  • 4,569
  • 4
  • 31
  • 42