import matplotlib.pyplot as plt
import numpy as np
# Data points based on the visual interpretation
t_values = np.array([0, 1, 2, 3])
# Assuming r_peak = 1 and r_trough = -0.5
r_peak_value = 1.0
r_trough_value = -0.5
r_values = np.array([0, r_peak_value, 0, r_trough_value])
# Colors from the image (approximated)
line_color = 'deeppink'
axis_color = 'deeppink'
dashed_line_color = 'lightskyblue' # or 'cyan'
tick_label_color = 'lightskyblue'
plt.figure(figsize=(6, 5))
# Plot the main graph line
plt.plot(t_values, r_values, color=line_color, linewidth=2)
# Add vertical dashed lines
# From t=1, r=0 to t=1, r=r_peak_value
plt.plot([1, 1], [0, r_peak_value], color=dashed_line_color, linestyle='--', dashes=(4, 4), linewidth=1)
# From t=3, r=0 to t=3, r=r_trough_value
plt.plot([3, 3], [0, r_trough_value], color=dashed_line_color, linestyle='--', dashes=(4, 4), linewidth=1)
# Style the axes to look like the image
ax = plt.gca()
# Remove top and right spines
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
# Color and position bottom and left spines to act as axes
ax.spines['bottom'].set_position('zero')
ax.spines['bottom'].set_color(axis_color)
ax.spines['bottom'].set_linewidth(1.5)
ax.spines['left'].set_position('zero')
ax.spines['left'].set_color(axis_color)
ax.spines['left'].set_linewidth(1.5)
# Set ticks and labels for the x-axis (t-axis)
plt.xticks([0, 1, 2, 3], labels=['O', '1', '2', '3'], color=tick_label_color)
# Remove y-axis ticks and labels (as they are not prominent in the image)
plt.yticks([])
# Add axis labels 't' and 'r' at the end of the axes
# For 't' label at the right end of the x-axis
plt.text(max(t_values) + 0.1, -0.05, 't', color=axis_color, ha='left', va='top', fontsize=12)
# For 'r' label at the top end of the y-axis
max_r_for_label = max(r_peak_value, abs(r_trough_value)) + 0.2 # Determine a good y-pos for 'r'
plt.text(-0.05, max_r_for_label, 'r', color=axis_color, ha='right', va='top', fontsize=12, rotation=0)
# Set axis limits to give some padding and make arrows visible
plt.xlim(-0.2, max(t_values) + 0.3)
plt.ylim(min(r_trough_value, 0) - 0.3, max(r_peak_value, 0) + 0.3)
# Add arrowheads to the axes (simplified version)
# For x-axis (t)
ax.plot(1, 0, ">", transform=ax.get_yaxis_transform(), clip_on=False, color=axis_color, markersize=8)
# For y-axis (r)
ax.plot(0, 1, "^", transform=ax.get_xaxis_transform(), clip_on=False, color=axis_color, markersize=8)
plt.grid(False) # No grid in the original image
plt.title("r vs t Graph", color=line_color) # Optional title
plt.show()