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