@@ -1254,5 +1254,57 @@ def test_canvas_fontsize_controls_axes_text():
12541254 assert fig ._suptitle .get_fontsize () == pytest .approx (10 )
12551255
12561256
1257+ def test_get_matplotlib_figaxs_returns_native_figure_and_axes ():
1258+ from maxplotlib import Canvas
1259+
1260+ canvas = Canvas ()
1261+ canvas .plot ([0 , 1 , 2 ], [0 , 1 , 4 ], label = "line" )
1262+
1263+ figure , axes = canvas .get_matplotlib_figaxs ()
1264+
1265+ assert figure .__class__ .__name__ == "Figure"
1266+ assert axes .shape == (1 , 1 )
1267+ # The returned axes are the canvas's real Matplotlib objects, editable
1268+ # with the native API for anything maxplotlib doesn't wrap.
1269+ axes [0 ][0 ].set_title ("edited directly" )
1270+ assert axes [0 ][0 ].get_title () == "edited directly"
1271+
1272+
1273+ def test_get_plotly_fig_returns_native_figure ():
1274+ from maxplotlib import Canvas
1275+
1276+ canvas = Canvas ()
1277+ canvas .plot ([0 , 1 , 2 ], [0 , 1 , 4 ], label = "line" )
1278+
1279+ figure = canvas .get_plotly_fig ()
1280+
1281+ assert figure .__class__ .__name__ == "Figure"
1282+ assert len (figure .data ) == 1
1283+ figure .update_traces (marker = dict (size = 20 ))
1284+ assert figure .data [0 ].marker .size == 20
1285+
1286+
1287+ def test_get_plotext_fig_returns_native_figure ():
1288+ from maxplotlib import Canvas
1289+
1290+ canvas = Canvas ()
1291+ canvas .plot ([0 , 1 , 2 ], [0 , 1 , 4 ], label = "line" )
1292+
1293+ figure = canvas .get_plotext_fig ()
1294+
1295+ assert figure .__class__ .__name__ == "PlotextFigure"
1296+
1297+
1298+ def test_get_tikz_figure_returns_native_figure ():
1299+ from maxplotlib import Canvas
1300+
1301+ canvas = Canvas ()
1302+ canvas .plot ([0 , 1 , 2 ], [0 , 1 , 4 ], label = "line" )
1303+
1304+ figure = canvas .get_tikz_figure ()
1305+
1306+ assert figure .__class__ .__name__ == "TikzFigure"
1307+
1308+
12571309if __name__ == "__main__" :
12581310 test ()
0 commit comments