0

I want to plot several plots into one plot using matplotlib.pyplot.subplots.

The subplot that I have so far looks as follows:

enter image description here

Currently, each plot is really small which does not allow for clear interpretation.

What I would like to do is stretch both the x- as well as the y-axis.

To do this, I tried:

fig, axs = plt.subplots(7, 3)

f_c1 = fuzz.gaussmf(f_range, mean=0.1, sigma = 0.40)
f_c2 = fuzz.gaussmf(f_range, mean=0.1, sigma=0.15)
axs[0, 0].plot(f_range, f_c1, 'b', linewidth = 1.5)
axs[0, 0].plot(f_range, f_c2, 'r', linewidth = 1.5)
axs[0, 0].scatter(input_achiever.T[:,0], u_achiever.T[:,0], color='b')
axs[0, 0].scatter(input_achiever.T[:,0], u_achiever.T[:,1], marker='+', color='r')
axs[0, 0].set_title('Points')
axs[0.0].plt.figure(figsize=(4,4))

However, nothing changed after running this code.

Also, I have tried:

fig, axs = plt.subplots(7, 3)

    f_c1 = fuzz.gaussmf(f_range, mean=0.1, sigma = 0.40)
    f_c2 = fuzz.gaussmf(f_range, mean=0.1, sigma=0.15)
    axs[0, 0].plot(f_range, f_c1, 'b', linewidth = 1.5, figsize=(8, 6))
    axs[0, 0].plot(f_range, f_c2, 'r', linewidth = 1.5, figsize=(8, 6))
    axs[0, 0].scatter(input_achiever.T[:,0], u_achiever.T[:,0], color='b')
    axs[0, 0].scatter(input_achiever.T[:,0], u_achiever.T[:,1], marker='+', color='r')
    axs[0, 0].set_title('Points')
    axs[0.0].plt.figure(figsize=(4,4))

Based on this question

And this did't work either for me.

Who can help me to stretch my axes?

Emil
  • 1,531
  • 3
  • 22
  • 47
  • 1
    Why don't you use a wider figure like `fig, axs = plt.subplots(15, 5)` or something of this sort and then use `plt.tight_layout()` – Sheldore Jun 08 '20 at 09:56
  • I thought about that as well, but the document that Im going to use this plot in allows for more space. So therefore, I would like to stretch the picture – Emil Jun 08 '20 at 09:58
  • 1
    But isn't strecthing the same thing as using a wider figure in the first place? You have to specify clearly what didn't work for you with `figsize` – Sheldore Jun 08 '20 at 10:03
  • When I did that, I got an error: IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices – Emil Jun 08 '20 at 10:35
  • 1
    The default figure size is 6.4" by 4.8", you could try something like`fig, axs = plt.subplots(7, 3, figsize=(10, 8))` – gboffi Jun 08 '20 at 12:28

0 Answers0