Understood! I'll update the height range for the graph to focus on the more relevant segment from 140 cm to 200 cm.
import numpy as np
import matplotlib.pyplot as plt
# Your current data
user_height_cm = 183
user_weight_kg = 75
user_height_m = user_height_cm / 100
# Calculate the offset for Index 1 based on your interpretation
# Target weight by formula = user_height_cm - 110 = 183 - 110 = 73 kg
# Your actual weight = 75 kg
# Offset = Your actual weight - (Target weight by formula) = 75 - 73 = +2 kg
index1_offset = user_weight_kg - (user_height_cm - 110) # This will be 2
# Calculate your current BMI value
current_bmi_value = user_weight_kg / (user_height_m ** 2) # Approx 22.40
# Calculate your current Index 3 value
current_index3_value = user_weight_kg / (user_height_m ** 3) # Approx 12.30
# Define the new height range for the x-axis of the graph (in cm)
# Changed from 100-220 to 140-200
heights_cm_range = np.linspace(140, 200, 200)
heights_m_range = heights_cm_range / 100
# Calculate weights for each height to maintain the respective conditions
# 1. Weight for Adjusted Index 1: (h - 110) + offset
weights_for_index1_adjusted = (heights_cm_range - 110) + index1_offset
# 2. Weight for constant BMI
weights_for_constant_bmi = current_bmi_value * (heights_m_range ** 2)
# 3. Weight for constant Index 3
weights_for_constant_index3 = current_index3_value * (heights_m_range ** 3)
# Plotting
plt.figure(figsize=(12, 7))
plt.plot(heights_cm_range, weights_for_index1_adjusted, label=f'Index 1 Adjusted: (Height - 110) + {index1_offset:.0f} kg')
plt.plot(heights_cm_range, weights_for_constant_bmi, label=f'Maintain BMI of {current_bmi_value:.2f}')
plt.plot(heights_cm_range, weights_for_constant_index3, label=f'Maintain Index 3 of {current_index3_value:.2f}')
# Mark your current position
plt.plot(user_height_cm, user_weight_kg, 'ko', markersize=8, label=f'Your Point ({user_height_cm}cm, {user_weight_kg}kg)')
plt.title('Weight Required at Different Heights to Match Your Current Index Characteristics')
plt.xlabel('Height (cm)')
plt.ylabel('Weight (kg)')
plt.legend()
plt.grid(True)
plt.ylim(bottom=0) # Ensure weight doesn't go negative on the plot
plt.xlim(140, 200) # Set X-axis limits to 140 to 200 cm
plt.show()
The graph now focuses on the height range of 140 cm to 200 cm, giving a clearer view within that more common adult height spectrum.