Python Forum

Full Version: Help With Sub Plots
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all

I was wondering if anyone could help with my understanding when it comes to sub plotting.

I have looked at the documentation and examples for creating sub plots.

The firstly the example i found on the matplot lib web site shows how to create a sub plot.

# Create two subplots and unpack the output array immediately
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
ax1.plot(x, y)
ax1.set_title('Sharing Y axis')
ax2.scatter(x, y)
What is the purpose of the letter f or fig on line 2, i can remove or replace the letter f and the code works fine, can anyone tell me what this letter means/refers to?

I am trying to create a figure which contains 3 subplots i.e. 3 rows and 1 column.

I have started the code off as:-

pyplot.figure("Wall_Height", figsize=(5,5))
This creates a new figure window called Wall Height and is of size 5 x 5.

Within this figure window i want to create 3 subplots i have attempted to do this using the following code:-

Wall_Height, (plot1, plot2, plot3) = pyplot.subplots(3,1)
But all this does is create an empty figure window called Wall_Height and a second figure window with the empty subplots.

How can i create the sub plots within my figure window called Wall_Height?

Attached is a screen shot of the plots and code.

Any help will be greatly appreciated.

Thank you.