Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Plotting issue Matplotlib
#1
fig = plt.figure() # create figure

ax0 = fig.add_subplot(1, 2, 1) # add subplot 1 (1 row, 2 columns, first plot)
ax1 = fig.add_subplot(1, 2, 2) # add subplot 2 (1 row, 2 columns, second plot). See tip below**
ax2 = fig.add_subplot(2, 2, 3) # add subplot 1 (1 row, 2 columns, first plot)
ax3 = fig.add_subplot(2, 2, 4) # add subplot 2 (1 row, 2 columns, second plot). See tip below**


# Subplot 1
df_countries.plot(kind='scatter', x='Years', y='Brazil',figsize=(20, 6), ax=ax0) # add to subplot 2
ax0.set_title ('Total Immigration to Canada between 1980 - 2013 from Brazil')
ax0.set_ylabel('Number of Immigrants')
ax0.set_xlabel('Years')

# Subplot 2:
df_countries.plot(kind='scatter', x='Years', y='Norway',figsize=(20, 6), ax=ax1) # add to subplot 2
ax1.set_title ('Total Immigration to Canada between 1980 - 2013 from Norway')
ax1.set_ylabel('Number of Immigrants')
ax1.set_xlabel('Years')

# Subplot 3: 
df_countries.plot(kind='scatter', x='Years', y='Denmark',figsize=(20, 6), ax=ax2) # add to subplot 2
ax2.set_title ('Total Immigration to Canada between 1980 - 2013 from Denmark')
ax2.set_ylabel('Number of Immigrants')
ax2.set_xlabel('Years')

# Subplot 4: 
df_countries.plot(kind='scatter', x='Years', y='Sweden',figsize=(20, 6), ax=ax3) # add to subplot 2
ax3.set_title ('Total Immigration to Canada between 1980 - 2013 from Sweden')
ax3.set_ylabel('Number of Immigrants')
ax3.set_xlabel('Years')
when I use this code to create subplots the graphs overlay horizontally. Does anybody knows how to make each graph display properly? I generate graphs on Jupiter notebook.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  matplotlib pyplot ginput issue MLiljeroth 0 1,206 Oct-12-2018, 07:12 AM
Last Post: MLiljeroth
  Issue plotting coordinates using Basemap kiton 5 4,673 Mar-09-2017, 07:33 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)