Lock aspect ratio in Tableau is a setting that ensures the original shape of an image remains consistent when displayed within a visualization.
Understanding Lock Aspect Ratio
When you add an image to a Tableau visualization, such as a background image for a map or a corporate logo, you might need to control how it scales or stretches. The "lock aspect ratio" setting prevents Tableau from distorting the image by forcing it to maintain its original width-to-height proportion.
Based on the provided reference:
Lock aspect ratio means Tableau won't change the aspect ratio of the image when it is displayed on the viz.
This is crucial for maintaining the visual integrity of the image. If the aspect ratio were not locked, and the container for the image in the visualization changed shape (e.g., from a square to a rectangle), the image would stretch or compress to fill the new shape, often making it look warped.
Image Coordinates vs. Viz Coordinates
The reference also highlights an important distinction:
But the mapping from image coordinates to viz coordinates does not need to have the same ratio in both dimensions.
This means while the image itself keeps its original shape (aspect ratio) when displayed, the way its internal points (image coordinates) correspond to the data points or positions within the Tableau visualization (viz coordinates) can still be adjusted independently along the x and y axes.
Key takeaways:
- Image Appearance: The visual shape of the image (its aspect ratio) is preserved. It won't look stretched or squashed.
- Data Mapping: The scaling relationship between points within the image and points on the visualization axes can still be non-proportional. This allows you to align the image correctly with your data points or background map, even if the image isn't a perfect 1:1 scale representation of the viz space.
Practical Applications
- Background Images: When using a floor plan, a custom map, or a diagram as a background image, locking the aspect ratio ensures the plan or map looks correct, while you still have flexibility to align specific locations on the image with data points using the X and Y axis mapping.
- Logos or Graphics: Displaying company logos or other graphic elements without distortion is vital for branding and clear communication.
In essence, locking the aspect ratio controls the visual display of the image itself, separate from how its spatial dimensions relate to the data axes in the visualization.