Coverage for src/min_circle/utils/figure.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-19 00:41 +0000

1"""Figure utility module for creating and configuring Plotly figures. 

2 

3This module provides functions for creating pre-configured Plotly figures 

4for visualizing circles and point clouds. 

5""" 

6 

7import plotly.graph_objects as go 

8 

9 

10def create_figure() -> go.Figure: 

11 """Create a pre-configured Plotly figure with equal aspect ratio. 

12 

13 Creates a new Plotly figure with an equal aspect ratio between x and y axes, 

14 which is important for correctly visualizing circles. 

15 

16 Returns: 

17 A configured Plotly Figure object ready for adding traces 

18 """ 

19 # Create an empty figure 

20 fig = go.Figure() 

21 

22 # Update layout for equal aspect ratio and axis labels 

23 fig.update_layout( 

24 xaxis_title="x", 

25 yaxis_title="y", 

26 # Ensure equal scaling for x and y axes (important for circles) 

27 yaxis=dict( 

28 scaleanchor="x", 

29 scaleratio=1, 

30 ), 

31 ) 

32 

33 return fig