@@ -1150,6 +1150,26 @@ def test_uneven_custom_date_xtickvals_are_converted():
11501150 )
11511151
11521152
1153+ def test_custom_date_xtickvals_given_as_numbers_are_converted ():
1154+ """Custom date ticks given as matplotlib date numbers must be converted
1155+ to date strings."""
1156+ import matplotlib .dates as mdates
1157+
1158+ dates = [datetime .datetime (2023 , 1 , i ) for i in range (1 , 11 )]
1159+ fig , ax = plt .subplots ()
1160+ ax .plot (dates , np .random .rand (10 ))
1161+ ax .set_xticks ([mdates .date2num (d ) for d in dates [::3 ]])
1162+
1163+ plotly_fig = tls .mpl_to_plotly (fig )
1164+
1165+ assert plotly_fig .layout .xaxis .tickvals == (
1166+ "2023-01-01 00:00:00" ,
1167+ "2023-01-04 00:00:00" ,
1168+ "2023-01-07 00:00:00" ,
1169+ "2023-01-10 00:00:00" ,
1170+ )
1171+
1172+
11531173def test_fill_converts ():
11541174 """plt.fill polygons convert to filled scatter traces."""
11551175 x = np .linspace (0 , 2 * np .pi , 50 )
@@ -1350,26 +1370,6 @@ def test_circle_outline_points_lie_on_the_circle():
13501370 assert np .allclose (np .hypot (x - 0.5 , y - 0.5 ), 0.3 , atol = 1e-3 )
13511371
13521372
1353- def test_custom_date_xtickvals_given_as_numbers_are_converted ():
1354- """Custom date ticks given as matplotlib date numbers must be converted
1355- to date strings."""
1356- import matplotlib .dates as mdates
1357-
1358- dates = [datetime .datetime (2023 , 1 , i ) for i in range (1 , 11 )]
1359- fig , ax = plt .subplots ()
1360- ax .plot (dates , np .random .rand (10 ))
1361- ax .set_xticks ([mdates .date2num (d ) for d in dates [::3 ]])
1362-
1363- plotly_fig = tls .mpl_to_plotly (fig )
1364-
1365- assert plotly_fig .layout .xaxis .tickvals == (
1366- "2023-01-01 00:00:00" ,
1367- "2023-01-04 00:00:00" ,
1368- "2023-01-07 00:00:00" ,
1369- "2023-01-10 00:00:00" ,
1370- )
1371-
1372-
13731373def test_tick_label_color_exports ():
13741374 """Tick label colors are exported to the plotly tickfont."""
13751375 fig , ax = plt .subplots ()
0 commit comments