Created
January 26, 2020 02:15
-
-
Save Perishleaf/1d2e9dd4507e53ae3e21eb61b7bf9ef2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set canvas background color the same as axes | |
plt.rc('figure', facecolor='w') | |
# Arrange city based on latitude | |
cityList = ['hobart', 'melbourne', 'canberra', 'adelaide', 'sydney', 'perth', 'brisbane', 'darwin'] | |
# set constrianed_layout as True to avoid axes overlap | |
fig = plt.figure(figsize=(10,12), dpi=300, constrained_layout=True) | |
# Use GridSpec for customising layout | |
gs = fig.add_gridspec(nrows=10, ncols=10) | |
# Set up a empty axes that occupied 2 rows and 10 cols in the grid for text | |
axText = fig.add_subplot(gs[0:2, :]) | |
axText.annotate('I am ax1', (0.5, 0.5), | |
xycoords='axes fraction', va='center', ha='center') | |
axText.get_xaxis().set_visible(False) | |
axText.get_yaxis().set_visible(False) | |
# Add a color bar on top of axText, using figure coordinates | |
axInlet = fig.add_axes([0.9, 0.97, 0.08, 0.01], frameon=True) | |
axInlet.annotate('I am ax2', (0.5, 0.5), | |
xycoords='axes fraction', va='center', ha='center') | |
axInlet.get_xaxis().set_visible(False) | |
axInlet.get_yaxis().set_visible(False) | |
# Add axes for temperature bar plots that each occupy 1 row and 8 cols in the grid | |
for i, city in enumerate(cityList): | |
ax = fig.add_subplot(gs[i+2, 0:8], ylim=(-30, 30)) | |
ax.annotate('I am ax{}'.format(i+3), (0.5, 0.5), | |
xycoords='axes fraction', va='center', ha='center') | |
ax.get_xaxis().set_visible(False) | |
ax.get_yaxis().set_visible(False) | |
# Add axes for rainfall that each occipy 1 row and 2 cols in the grid | |
for i, city in enumerate(cityList): | |
axRain = fig.add_subplot(gs[i+2, 8:10], ylim=(-30, 30)) | |
axRain.annotate('I am ax{}'.format(i+11), (0.5, 0.5), | |
xycoords='axes fraction', va='center', ha='center') | |
axRain.get_xaxis().set_visible(False) | |
axRain.get_yaxis().set_visible(False) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment