0

I am plotting a large plot with 12 subplots, and I noticed a new output from the program to the terminal that is not caused by the program or its dependencies.

After commenting out each of my graphs, I saw that it was coming from a subplot's ax.set_xlim([0, dur]) command. No other plot I have made causes the x-axis limit to print, so I am very confused.

Below is a compressed version of the plot I am making:

fig = plt.figure(3)
plt.rcParams["font.family"] = "serif"
fig.set_size_inches(10, 12)
fig.tight_layout()

# r
ax12 = plt.subplot(6,2,8)
ax12.grid(linestyle='--',linewidth=1.25)
ax12.set(ylabel = r'$r$ ($^\circ$/s)')
ax12.plot(t_steps[0:i], X[0:i,8]*57.3, 'b')
ax12.set_xlim([0, dur])

In the terminal, I get:

(0.0, 130.0)

I am still relatively new to python but I can't find this online anywhere.

jared
  • 4,165
  • 1
  • 8
  • 31

1 Answers1

1

When running code in a Jupyter notebook, if the last line of a cell returns something (such as a function that returns a value or just writing a variable), the that return value will be printed out.

In this case, calling ax.set_xlim returns a tuple of the limits. Since it is the last line in that cell, the return is printed to the console.

As @BigBen suggested, to suppress the output, you can place a semicolon at the end of the line.

jared
  • 4,165
  • 1
  • 8
  • 31