create two subplots: subplot 1 – line plot of “nl10138” and “nl10538” over time and subplot 2 – line plot of nl10636 versus nl10643 over time. in python

Here is an example code to create two subplots of line plots in a single figure using Python's Matplotlib library:

main.py
import matplotlib.pyplot as plt
import pandas as pd

# create sample data
data = {'time': ['2022-01-01', '2022-02-01', '2022-03-01', '2022-04-01', '2022-05-01', '2022-06-01', '2022-07-01', '2022-08-01'],
        'nl10138': [10, 20, 15, 30, 25, 35, 30, 40],
        'nl10538': [5, 15, 10, 25, 20, 30, 25, 35],
        'nl10636': [8, 18, 13, 28, 23, 33, 28, 38],
        'nl10643': [6, 16, 11, 26, 21, 31, 26, 36]}

df = pd.DataFrame(data)
df['time'] = pd.to_datetime(df['time'])
df.set_index('time', inplace=True)

# create subplots
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))

# subplot 1
ax1.plot(df.index, df['nl10138'], label='nl10138')
ax1.plot(df.index, df['nl10538'], label='nl10538')
ax1.set_title('nl10138 and nl10538 over time')
ax1.set_xlabel('Time')
ax1.set_ylabel('Values')
ax1.legend()

# subplot 2
ax2.plot(df.index, df['nl10636'], label='nl10636')
ax2.plot(df.index, df['nl10643'], label='nl10643')
ax2.set_title('nl10636 vs nl10643 over time')
ax2.set_xlabel('Time')
ax2.set_ylabel('Values')
ax2.legend()

plt.show()
1043 chars
35 lines

This code will produce a figure with two subplots. The first subplot will contain line plots of "nl10138" and "nl10538" over time, and the second subplot will contain line plots of "nl10636" versus "nl10643" over time.

Note that in this example, I have used Pandas library to create a sample dataframe with time series data to plot. You can replace this with your own data as needed.

gistlibby LogSnag