Okay, here's a Python script using matplotlib to generate the diagram. It will draw centered, layered rectangles with the specified colors and dimensions, including text labels for clarity.
import matplotlib.pyplot as plt
import matplotlib.patches as patches
def create_resolution_diagram():
"""
Generates a diagram overlaying different sensor and output resolutions.
Each rectangle is centered and colored as specified.
"""
# Define resolutions, colors, and names
# Note: 'violet' is mapped to 'darkviolet' for better visibility against dark backgrounds.
# 'yellow' is mapped to 'gold' for better distinction.
# 'green' is mapped to 'forestgreen' for better distinction.
resolutions_data = [
{"name": "Full-frame sensor", "label": "Black: Full-frame (6192x4128)", "color": "black", "width": 6192, "height": 4128},
{"name": "APS-C sensor", "label": "Red: APS-C sensor (4660x3100)", "color": "red", "width": 4660, "height": 3100},
{"name": "APS-C RAW output", "label": "Blue: APS-C RAW (4672x2628)", "color": "blue", "width": 4672, "height": 2628},
{"name": "Full-frame RAW output", "label": "Violet: Full-frame RAW (4264x2408)", "color": "darkviolet", "width": 4264, "height": 2408},
{"name": "DCI 4K", "label": "Yellow: DCI 4K (4096x2160)", "color": "gold", "width": 4096, "height": 2160},
{"name": "UHD 4K", "label": "Green: UHD 4K (3840x2160)", "color": "forestgreen", "width": 3840, "height": 2160},
]
# Sort resolutions by area in descending order.
# This means the largest rectangle will be at index 0, and the smallest at the last index.
# We will draw them in this order, assigning `zorder=i` so the smallest (last in this sorted list)
# gets the highest zorder and appears on top.
resolutions_data.sort(key=lambda r: r['width'] * r['height'], reverse=True)
# Determine the maximum width and height for plot limits, based on the largest rectangle
max_width = resolutions_data[0]['width']
max_height = resolutions_data[0]['height']
# Add some padding around the largest rectangle for better visual margins
padding_x = max_width * 0.05
padding_y = max_height * 0.05
# Set up the plot
fig, ax = plt.subplots(figsize=(12, 9)) # Adjust figure size as needed
# Set plot limits based on the largest rectangle and padding
ax.set_xlim(-padding_x, max_width + padding_x)
ax.set_ylim(-padding_y, max_height + padding_y)
# Remove axes, ticks, and frame for a clean diagram look
ax.axis('off')
ax.set_aspect('equal', adjustable='box') # Ensure rectangles are not distorted
# Draw rectangles and add labels
for i, res in enumerate(resolutions_data):
width, height = res['width'], res['height']
color = res['color']
label = res['label']
# Calculate bottom-left corner to center the rectangle within the overall plot area
x = (max_width - width) / 2
y = (max_height - height) / 2
# Create rectangle patch
# `zorder=i` ensures that rectangles later in the sorted list (which are smaller)
# are drawn on top of earlier ones (larger).
rect = patches.Rectangle((x, y), width, height,
linewidth=1.5, edgecolor='darkgray', facecolor=color, alpha=0.7,
zorder=i)
ax.add_patch(rect)
# Add text label (centered within each rectangle)
text_x = x + width / 2
text_y = y + height / 2
# Determine text color for optimal visibility against the rectangle's color
text_color = 'white'
if color in ['red', 'gold']: # These colors are light enough for black text
text_color = 'black'
ax.text(text_x, text_y, label,
color=text_color, ha='center', va='center', fontsize=9,
# Add a semi-transparent white background to the text for better readability
bbox=dict(facecolor='white', alpha=0.5, edgecolor='none', boxstyle='round,pad=0.2')
)
# Add a title to the diagram
ax.set_title("Sensor & Output Resolution Overlay Diagram", fontsize=16, pad=20)
plt.tight_layout() # Adjusts plot parameters for a tight layout
plt.show() # Display the plot
# Call the function to create and display the diagram
if __name__ == "__main__":
create_resolution_diagram()
How to Run the Code:
- Install Matplotlib: If you don't have it, open your terminal or command prompt and run:
pip install matplotlib
- Save the Code: Save the code above into a Python file (e.g.,
resolution_diagram.py).
- Run from Terminal: Navigate to the directory where you saved the file and run:
python resolution_diagram.py
This will open a new window displaying the layered diagram.
Diagram Explanation:
- Black (Full-frame sensor): This is the largest rectangle, representing the full-frame sensor's total area. All other resolutions are contained within or overlay it.
- Red (APS-C sensor): This rectangle is smaller than the full-frame sensor, showing the typical APS-C crop factor.
- Blue (APS-C RAW output): Noticeably, this is slightly wider than the red APS-C sensor, but significantly shorter (a different aspect ratio, likely 16:9 for video output). It still fits within the full-frame sensor.
- Violet (Full-frame RAW output): This is a cropped output from the full-frame sensor, showing a specific video or RAW capture resolution. It's smaller than the full sensor but often larger than 4K video outputs.
- Yellow (DCI 4K): Represents the cinema standard 4K resolution (4096 pixels wide). It's a common video output/recording size.
- Green (UHD 4K): Represents the consumer standard 4K resolution (3840 pixels wide). It's the narrowest rectangle, as UHD 4K is slightly narrower than DCI 4K, though both have the same height of 2160 pixels.
The diagram clearly illustrates the relative sizes and aspect ratios, showing how different resolutions relate to the physical sensor sizes and each other.