enter image description here
I have created a graph in python that has 4 different graphs on the same x axis. However, there is a problem that a second straight line has been formed as seen on the Pressure variables. Does anyone know to remove these lines as the seem to be from last reading of the data have imported.
I was only expecting a single line but it has resulted in the end result being a line as as well the actual data. I have included the code that I believe that is creating that second line but I can’t figure out why or how to remove it? Any help will be much appreciated.
# Convert 'Date and Time' column to datetime
df['Date and Time'] = pd.to_datetime(df['Date and Time'])
# Set 'Date and Time' column as the index
df.set_index('Date and Time', inplace=True)
# Create a figure and a set of subplots with shared x-axis
fig, ax1 = plt.subplots(figsize=(12, 6))
# Set x-axis limits
# Set x-axis limits
start_date = pd.to_datetime('2024-04-19')
end_date = pd.to_datetime('2024-05-01') # Adjust the end date here
ax1.set_xlim(start_date, end_date) # Set the x-axis limits to the desired range
# Generate x-axis ticks at 3-day intervals
date_range = pd.date_range(start=start_date, end=end_date, freq='3D')
ax1.set_xticks(date_range)
# Format x-axis labels to show date only
ax1.xaxis.set_major_formatter(plt.matplotlib.dates.DateFormatter("%Y-%m-%d"))
Kenny Hignett is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.