matplotlib - Annotate each subplot from a list - Stack Overflow
I have a large dataframe that I need to make and annotate subplots from, see below. Everything seems ok, I still have some work to do on the x and y ticks but otherwise it seems pretty right, except, I can't get the annotation for each subplot to fall on the appropriate subplot. The annotations are all taken from the list 'df_cols' defined at the start. All of the annotation are plotted, but on top of one another in the lowest subplot, which is also the last subplot in the list.
df_cols = ['WC_015', 'WC_030', 'WC_046', 'WC_061', 'WC_076', 'WC_091', 'WC_107', 'WC_122', 'WC_137', 'WC_152', 'WC_168', 'WC_183', 'WC_213', 'WC_244', 'WC_274', 'WC_305', 'WC_366', 'WC_427', 'WC_488', 'WC_518']
fig, axs = plt.subplots(20, 1, figsize=(50,30)) #, sharex=True, sharey=True)
for k, col in enumerate(df_cols):
df[col].plot(ax=axs[k])
plt.annotate(df_cols[k], xy=(.01, .115), xycoords='axes fraction', fontsize=15, rotation=90, color='red') #plt.annotate(df_cols[k], xy=(.01, .115), xycoords='axes fraction', fontsize=15, rotation=90, color='red')
fig.subplots_adjust(hspace=0)
plt.suptitle ('Volumetric Moisture Content', fontsize=40, y=.91)
plt.ylabel('Volumetric Moisture Content (m3/m3)', fontsize=30, y=10.0)
plt.xlabel('Date', fontsize=30)
plt.savefig('Moisture_Content_Plots.pdf', dpi=100, bbox_inches='tight')
It seems like it should iterate through the labels with the loop that makes the subplots, but I can't get it there.
最新文章
- Windows 8取胜机会:10个值得考虑的因素
- 2020年或诞生超级计算机:相当5000万台笔记本
- Docker environment for aya rust ebpf compilation - Stack Overflow
- python - Error with modules aiogram 3.0, how to fix? - Stack Overflow
- soa - How to use a variable in a composite or wsdl, as I need to have this variable per environment? - Stack Overflow
- visual studio code - Why am I getting “Type annotations can only be used in TypeScript files” with tsx files? - Stack Overflow
- rust - Basic bracket-lib example crashes with “unsafe precondition(s) violated: slice::from_raw_parts” - Stack Overflow
- html - Disable scrolling. Overflow:hidden not working - Stack Overflow
- asynchronous - Parallelization by threads vs Parallelization by processes on backend - Stack Overflow
- php - No client_secret for Stripe Elements with Subscription billing_cycle_anchor - Stack Overflow
- java - Bluej throws SSLHandshakeException making http request - Stack Overflow
- javascript - Unable to locate tests within a folder - Stack Overflow
- solrcloud - How to use "or" in an eDisMax query in Solr 9.4? - Stack Overflow
- c# - Having trouble getting the correct position to draw my sprite to when rotating it - Stack Overflow
- scipy - Problem with a simple script in which the Librosa Python library does not work well for me - Stack Overflow
- macos - Image from ImagePicker in landscape - Stack Overflow
- python - How to optimise this simulation of a lottery? - Stack Overflow