@@ -3991,89 +3991,76 @@ def test_hlines():
3991
3991
ax5 .set_ylim (0 , 15 )
3992
3992
3993
3993
3994
- @image_comparison (
3995
- ['vlines_colors_basic' , 'vlines_colors_with_nan' , 'vlines_colors_masked' ],
3996
- extensions = ['png' ])
3997
- def test_vlines_with_colors ():
3998
- # normal
3999
- colors = ['red' , 'green' , 'blue' , 'purple' , 'orange' ]
4000
- x1 = [2 , 3 , 4 , 5 , 7 ]
4001
- y1 = [2 , - 6 , 3 , 8 , 2 ]
4002
- fig1 , ax1 = plt .subplots ()
4003
- ax1 .vlines (x1 , 0 , y1 , colors = colors , linewidth = 5 )
4004
-
4005
- # GH #7406
4006
- x2 = [2 , 3 , 4 , 5 , 6 , 7 ]
4007
- y2 = [2 , - 6 , 3 , 8 , np .nan , 2 ]
4008
- fig2 , (ax2 , ax3 , ax4 ) = plt .subplots (nrows = 3 , figsize = (4 , 8 ))
4009
- ax2 .vlines (x2 , 0 , y2 , colors = colors , linewidth = 5 )
4010
-
4011
- x3 = [2 , 3 , 4 , 5 , 6 , 7 ]
4012
- y3 = [np .nan , 2 , - 6 , 3 , 8 , 2 ]
4013
- ax3 .vlines (x3 , 0 , y3 , colors = colors , linewidth = 3 , linestyle = '--' )
4014
-
4015
- x4 = [2 , 3 , 4 , 5 , 6 , 7 ]
4016
- y4 = [np .nan , 2 , - 6 , 3 , 8 , np .nan ]
4017
- ax4 .vlines (x4 , 0 , y4 , colors = colors , linewidth = 2 )
4018
-
4019
- # tweak the x-axis so we can see the lines better
4020
- for ax in [ax1 , ax2 , ax3 , ax4 ]:
4021
- ax .set_xlim (0 , 10 )
4022
-
4023
- # check that the y-lims are all automatically the same
4024
- assert ax1 .get_ylim () == ax2 .get_ylim ()
4025
- assert ax1 .get_ylim () == ax3 .get_ylim ()
4026
- assert ax1 .get_ylim () == ax4 .get_ylim ()
3994
+ @check_figures_equal ()
3995
+ def test_vlines_with_nan_colors (fig_test , fig_ref ):
3996
+ colors1 = ['red' , 'green' , 'blue' , 'purple' , 'orange' , 'black' ]
3997
+ x1 = [2 , 3 , 4 , 5 , 6 , 7 ]
3998
+ y1 = [2 , - 6 , 3 , 8 , np .nan , 2 ]
4027
3999
4028
- fig3 , ax5 = plt .subplots ()
4029
- x5 = np .ma .masked_equal ([2 , 4 , 6 , 8 , 10 , 12 ], 8 )
4030
- ymin5 = np .ma .masked_equal ([0 , 1 , - 1 , 0 , 2 , 1 ], 2 )
4031
- ymax5 = np .ma .masked_equal ([13 , 14 , 15 , 16 , 17 , 18 ], 18 )
4032
- ax5 .vlines (x5 , ymin5 , ymax5 , colors = colors , linewidth = 2 )
4033
- ax5 .set_xlim (0 , 15 )
4000
+ fig_test , ax1 = plt .subplots ()
4001
+ ax1 .vlines (x1 , 0 , y1 , colors = colors1 , linewidth = 5 )
4034
4002
4003
+ colors2 = ['red' , 'green' , 'blue' , 'purple' , 'black' ]
4004
+ x2 = [2 , 3 , 4 , 5 , 7 ]
4005
+ y2 = [2 , - 6 , 3 , 8 , 2 ]
4006
+ # Reference image
4007
+ fig_ref , ax2 = plt .subplots ()
4008
+ ax2 .vlines (x2 , 0 , y2 , colors = colors2 , linewidth = 5 )
4035
4009
4036
- @image_comparison (
4037
- ['hlines_colors_basic' , 'hlines_colors_with_nan' , 'hlines_colors_masked' ],
4038
- extensions = ['png' ])
4039
- def test_hlines_with_colors ():
4040
4010
4041
- colors = ['red' , 'green' , 'blue' , 'purple' , 'orange' ]
4042
- # normal
4043
- y1 = [2 , 3 , 4 , 5 , 7 ]
4044
- x1 = [2 , - 6 , 3 , 8 , 2 ]
4045
- fig1 , ax1 = plt .subplots ()
4046
- ax1 .hlines (y1 , 0 , x1 , colors = colors , linewidth = 5 )
4011
+ @check_figures_equal ()
4012
+ def test_vlines_with_masked_colors (fig_test , fig_ref ):
4013
+ colors1 = ['red' , 'green' , 'blue' , 'purple' , 'orange' , 'black' ]
4014
+ fig_test , ax1 = plt .subplots ()
4015
+ x1 = np .ma .masked_equal ([2 , 4 , 6 , 8 , 10 , 12 ], 8 )
4016
+ ymin1 = np .ma .masked_equal ([0 , 1 , - 1 , 0 , 2 , 1 ], 2 )
4017
+ ymax1 = np .ma .masked_equal ([13 , 14 , 15 , 16 , 17 , 18 ], 18 )
4018
+ ax1 .vlines (x1 , ymin1 , ymax1 , colors = colors1 , linewidth = 2 )
4019
+ ax1 .set_xlim (0 , 15 )
4020
+
4021
+ colors2 = ['red' , 'green' , 'blue' ]
4022
+ fig_ref , ax2 = plt .subplots ()
4023
+ x2 = np .asarray ([2 , 4 , 6 ])
4024
+ ymin2 = np .asarray ([0 , 1 , - 1 ])
4025
+ ymax2 = np .asarray ([13 , 14 , 15 ])
4026
+ ax2 .vlines (x2 , ymin2 , ymax2 , colors = colors2 , linewidth = 2 )
4027
+ ax2 .set_xlim (0 , 15 )
4047
4028
4048
- # GH #7406
4049
- y2 = [2 , 3 , 4 , 5 , 6 , 7 ]
4050
- x2 = [2 , - 6 , 3 , 8 , np .nan , 2 ]
4051
- fig2 , (ax2 , ax3 , ax4 ) = plt .subplots (nrows = 3 , figsize = (4 , 8 ))
4052
- ax2 .hlines (y2 , 0 , x2 , colors = colors , linewidth = 5 )
4053
4029
4054
- y3 = [2 , 3 , 4 , 5 , 6 , 7 ]
4055
- x3 = [np .nan , 2 , - 6 , 3 , 8 , 2 ]
4056
- ax3 .hlines (y3 , 0 , x3 , colors = colors , linewidth = 3 , linestyle = '--' )
4030
+ @check_figures_equal ()
4031
+ def test_hlines_with_nan_colors (fig_test , fig_ref ):
4032
+ colors1 = ['red' , 'green' , 'blue' , 'purple' , 'orange' , 'black' ]
4033
+ x1 = [2 , 3 , 4 , 5 , 6 , 7 ]
4034
+ y1 = [2 , - 6 , 3 , 8 , np .nan , 2 ]
4057
4035
4058
- y4 = [2 , 3 , 4 , 5 , 6 , 7 ]
4059
- x4 = [np .nan , 2 , - 6 , 3 , 8 , np .nan ]
4060
- ax4 .hlines (y4 , 0 , x4 , colors = colors , linewidth = 2 )
4036
+ fig_test , ax1 = plt .subplots ()
4037
+ ax1 .vlines (y1 , 0 , x1 , colors = colors1 , linewidth = 5 )
4061
4038
4062
- # tweak the y-axis so we can see the lines better
4063
- for ax in [ax1 , ax2 , ax3 , ax4 ]:
4064
- ax .set_ylim (0 , 10 )
4039
+ colors2 = ['red' , 'green' , 'blue' , 'purple' , 'black' ]
4040
+ x2 = [2 , 3 , 4 , 5 , 7 ]
4041
+ y2 = [2 , - 6 , 3 , 8 , 2 ]
4042
+ # Reference image
4043
+ fig_ref , ax2 = plt .subplots ()
4044
+ ax2 .vlines (y2 , 0 , x2 , colors = colors2 , linewidth = 5 )
4065
4045
4066
- # check that the x-lims are all automatically the same
4067
- assert ax1 .get_xlim () == ax2 .get_xlim ()
4068
- assert ax1 .get_xlim () == ax3 .get_xlim ()
4069
- assert ax1 .get_xlim () == ax4 .get_xlim ()
4070
4046
4071
- fig3 , ax5 = plt .subplots ()
4072
- y5 = np .ma .masked_equal ([2 , 4 , 6 , 8 , 10 , 12 ], 8 )
4073
- xmin5 = np .ma .masked_equal ([0 , 1 , - 1 , 0 , 2 , 1 ], 2 )
4074
- xmax5 = np .ma .masked_equal ([13 , 14 , 15 , 16 , 17 , 18 ], 18 )
4075
- ax5 .hlines (y5 , xmin5 , xmax5 , colors = colors , linewidth = 2 )
4076
- ax5 .set_ylim (0 , 15 )
4047
+ @check_figures_equal ()
4048
+ def test_hlines_with_masked_colors (fig_test , fig_ref ):
4049
+ colors1 = ['red' , 'green' , 'blue' , 'purple' , 'orange' , 'black' ]
4050
+ fig_test , ax1 = plt .subplots ()
4051
+ y1 = np .ma .masked_equal ([2 , 4 , 6 , 8 , 10 , 12 ], 8 )
4052
+ xmin1 = np .ma .masked_equal ([0 , 1 , - 1 , 0 , 2 , 1 ], 2 )
4053
+ xmax1 = np .ma .masked_equal ([13 , 14 , 15 , 16 , 17 , 18 ], 18 )
4054
+ ax1 .vlines (y1 , xmin1 , xmax1 , colors = colors1 , linewidth = 2 )
4055
+ ax1 .set_xlim (0 , 15 )
4056
+
4057
+ colors2 = ['red' , 'green' , 'blue' ]
4058
+ fig_ref , ax2 = plt .subplots ()
4059
+ y2 = np .asarray ([2 , 4 , 6 ])
4060
+ xmin2 = np .asarray ([0 , 1 , - 1 ])
4061
+ xmax2 = np .asarray ([13 , 14 , 15 ])
4062
+ ax2 .vlines (y2 , xmin2 , xmax2 , colors = colors2 , linewidth = 2 )
4063
+ ax2 .set_xlim (0 , 15 )
4077
4064
4078
4065
4079
4066
@image_comparison (['step_linestyle' , 'step_linestyle' ], remove_text = True )
0 commit comments