@@ -2812,6 +2812,90 @@ def test_eb_line_zorder():
28122812 ax .set_title ("errorbar zorder test" )
28132813
28142814
2815+ @image_comparison (
2816+ baseline_images = ['vlines_basic' , 'vlines_with_nan' , 'vlines_masked' ],
2817+ extensions = ['png' ]
2818+ )
2819+ def test_vlines ():
2820+ # normal
2821+ x1 = [2 , 3 , 4 , 5 , 7 ]
2822+ y1 = [2 , - 6 , 3 , 8 , 2 ]
2823+ fig1 , ax1 = plt .subplots ()
2824+ ax1 .vlines (x1 , 0 , y1 , colors = 'g' , linewidth = 5 )
2825+
2826+ # GH #7406
2827+ x2 = [2 , 3 , 4 , 5 , 6 , 7 ]
2828+ y2 = [2 , - 6 , 3 , 8 , np .nan , 2 ]
2829+ fig2 , (ax2 , ax3 , ax4 ) = plt .subplots (nrows = 3 , figsize = (4 , 8 ))
2830+ ax2 .vlines (x2 , 0 , y2 , colors = 'g' , linewidth = 5 )
2831+
2832+ x3 = [2 , 3 , 4 , 5 , 6 , 7 ]
2833+ y3 = [np .nan , 2 , - 6 , 3 , 8 , 2 ]
2834+ ax3 .vlines (x3 , 0 , y3 , colors = 'r' , linewidth = 3 , linestyle = '--' )
2835+
2836+ x4 = [2 , 3 , 4 , 5 , 6 , 7 ]
2837+ y4 = [np .nan , 2 , - 6 , 3 , 8 , np .nan ]
2838+ ax4 .vlines (x4 , 0 , y4 , colors = 'k' , linewidth = 2 )
2839+
2840+ # tweak the x-axis so we can see the lines better
2841+ for ax in [ax1 , ax2 , ax3 , ax4 ]:
2842+ ax .set_xlim (0 , 10 )
2843+
2844+ # check that the y-lims are all automatically the same
2845+ assert ax1 .get_ylim () == ax2 .get_ylim ()
2846+ assert ax1 .get_ylim () == ax3 .get_ylim ()
2847+ assert ax1 .get_ylim () == ax4 .get_ylim ()
2848+
2849+ fig3 , ax5 = plt .subplots ()
2850+ x5 = np .ma .masked_equal ([2 , 4 , 6 , 8 , 10 , 12 ], 8 )
2851+ ymin5 = np .ma .masked_equal ([0 , 1 , - 1 , 0 , 2 , 1 ], 2 )
2852+ ymax5 = np .ma .masked_equal ([13 , 14 , 15 , 16 , 17 , 18 ], 18 )
2853+ ax5 .vlines (x5 , ymin5 , ymax5 , colors = 'k' , linewidth = 2 )
2854+ ax5 .set_xlim (0 , 15 )
2855+
2856+
2857+ @image_comparison (
2858+ baseline_images = ['hlines_basic' , 'hlines_with_nan' , 'hlines_masked' ],
2859+ extensions = ['png' ]
2860+ )
2861+ def test_hlines ():
2862+ # normal
2863+ y1 = [2 , 3 , 4 , 5 , 7 ]
2864+ x1 = [2 , - 6 , 3 , 8 , 2 ]
2865+ fig1 , ax1 = plt .subplots ()
2866+ ax1 .hlines (y1 , 0 , x1 , colors = 'g' , linewidth = 5 )
2867+
2868+ # GH #7406
2869+ y2 = [2 , 3 , 4 , 5 , 6 , 7 ]
2870+ x2 = [2 , - 6 , 3 , 8 , np .nan , 2 ]
2871+ fig2 , (ax2 , ax3 , ax4 ) = plt .subplots (nrows = 3 , figsize = (4 , 8 ))
2872+ ax2 .hlines (y2 , 0 , x2 , colors = 'g' , linewidth = 5 )
2873+
2874+ y3 = [2 , 3 , 4 , 5 , 6 , 7 ]
2875+ x3 = [np .nan , 2 , - 6 , 3 , 8 , 2 ]
2876+ ax3 .hlines (y3 , 0 , x3 , colors = 'r' , linewidth = 3 , linestyle = '--' )
2877+
2878+ y4 = [2 , 3 , 4 , 5 , 6 , 7 ]
2879+ x4 = [np .nan , 2 , - 6 , 3 , 8 , np .nan ]
2880+ ax4 .hlines (y4 , 0 , x4 , colors = 'k' , linewidth = 2 )
2881+
2882+ # tweak the y-axis so we can see the lines better
2883+ for ax in [ax1 , ax2 , ax3 , ax4 ]:
2884+ ax .set_ylim (0 , 10 )
2885+
2886+ # check that the x-lims are all automatically the same
2887+ assert ax1 .get_xlim () == ax2 .get_xlim ()
2888+ assert ax1 .get_xlim () == ax3 .get_xlim ()
2889+ assert ax1 .get_xlim () == ax4 .get_xlim ()
2890+
2891+ fig3 , ax5 = plt .subplots ()
2892+ y5 = np .ma .masked_equal ([2 , 4 , 6 , 8 , 10 , 12 ], 8 )
2893+ xmin5 = np .ma .masked_equal ([0 , 1 , - 1 , 0 , 2 , 1 ], 2 )
2894+ xmax5 = np .ma .masked_equal ([13 , 14 , 15 , 16 , 17 , 18 ], 18 )
2895+ ax5 .hlines (y5 , xmin5 , xmax5 , colors = 'k' , linewidth = 2 )
2896+ ax5 .set_ylim (0 , 15 )
2897+
2898+
28152899@image_comparison (baseline_images = ['step_linestyle' , 'step_linestyle' ],
28162900 remove_text = True )
28172901def test_step_linestyle ():
0 commit comments