plotting
plotting
Plotting utilities for planetary image data.
Provides common visualization helpers for planetary science: percentile stretching, grayscale image display, sun direction indicators.
Functions
| Name | Description |
|---|---|
| add_sun_indicator | Add a sun direction indicator to an image plot. |
| imshow_gray | Display a grayscale image with optional percentile stretch. |
| imshow_with_sun | Display a grayscale image with a sun direction indicator. |
| percentile_stretch | Compute display limits from percentiles, ignoring zeros and NaN. |
add_sun_indicator
plotting.add_sun_indicator(
ax,
sun_azimuth_deg,
position='upper right',
length=0.12,
color='yellow',
inner_color='orange',
)Add a sun direction indicator to an image plot.
The indicator shows a circle (sun) with a line pointing in the direction of illumination. The azimuth is measured clockwise from the top of the image.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ax | matplotlib.axes.Axes | The axes containing the image. | required |
| sun_azimuth_deg | float | Solar azimuth in degrees, clockwise from image top. This matches the PDS SUB_SOLAR_AZIMUTH convention for unprojected images. |
required |
| position | str | Where to place the indicator: “upper right”, “upper left”, “lower right”, “lower left”. | 'upper right' |
| length | float | Line length as fraction of image size (default 0.12). | 0.12 |
| color | str | Outer circle and line color. | 'yellow' |
| inner_color | str | Inner circle color (smaller, overlaid on outer). | 'orange' |
Returns
| Name | Type | Description |
|---|---|---|
| ax | matplotlib.axes.Axes |
imshow_gray
plotting.imshow_gray(
image,
stretch='1,99',
title=None,
ax=None,
**imshow_kwargs,
)Display a grayscale image with optional percentile stretch.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| image | 2D array | Image data. | required |
| stretch | str or None | Percentile stretch as “lo,hi” (e.g. “1,99”). Use None or “none” to disable. | '1,99' |
| title | str | Plot title. | None |
| ax | matplotlib.axes.Axes | Axes to plot on. Created if not provided. | None |
| **imshow_kwargs | Passed to ax.imshow(). | {} |
Returns
| Name | Type | Description |
|---|---|---|
| ax | matplotlib.axes.Axes |
imshow_with_sun
plotting.imshow_with_sun(
image,
sun_azimuth_deg,
title=None,
ax=None,
stretch='1,99',
sun_position='upper right',
**imshow_kwargs,
)Display a grayscale image with a sun direction indicator.
Combines imshow_gray with add_sun_indicator.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| image | 2D array | Image data. | required |
| sun_azimuth_deg | float | Solar azimuth in degrees, clockwise from image top. | required |
| title | str | Plot title. | None |
| ax | matplotlib.axes.Axes | Axes to plot on. Created if not provided. | None |
| stretch | str or None | Percentile stretch (default “1,99”). None to disable. | '1,99' |
| sun_position | str | Indicator position: “upper right”, “upper left”, etc. | 'upper right' |
| **imshow_kwargs | Passed to ax.imshow(). | {} |
Returns
| Name | Type | Description |
|---|---|---|
| ax | matplotlib.axes.Axes |
percentile_stretch
plotting.percentile_stretch(image, lo=1, hi=99)Compute display limits from percentiles, ignoring zeros and NaN.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| image | array - like | Image data (2D or nD). | required |
| lo | float | Lower and upper percentile (default 1, 99). | 1 |
| hi | float | Lower and upper percentile (default 1, 99). | 1 |
Returns
| Name | Type | Description |
|---|---|---|
| vmin, vmax : float | Display limits suitable for imshow(vmin=, vmax=). Returns (None, None) if no valid pixels. |