@@ -665,3 +665,77 @@ def test_check_tricontourf():
665665 assert "transform" in mocked .call_args .kwargs
666666 assert isinstance (mocked .call_args .kwargs ["transform" ], ccrs .PlateCarree )
667667 uplt .close (fig )
668+
669+
670+ def test_panels_geo ():
671+ fig , ax = uplt .subplots (proj = "cyl" )
672+ ax .format (labels = True )
673+ for dir in "top bottom right left" .split ():
674+ pax = ax .panel_axes (dir )
675+ match dir :
676+ case "top" :
677+ assert len (pax .get_xticklabels ()) > 0
678+ assert len (pax .get_yticklabels ()) > 0
679+ case "bottom" :
680+ assert len (pax .get_xticklabels ()) > 0
681+ assert len (pax .get_yticklabels ()) > 0
682+ case "left" :
683+ assert len (pax .get_xticklabels ()) > 0
684+ assert len (pax .get_yticklabels ()) > 0
685+ case "right" :
686+ assert len (pax .get_xticklabels ()) > 0
687+ assert len (pax .get_yticklabels ()) > 0
688+
689+
690+ @pytest .mark .mpl_image_compare
691+ def test_geo_with_panels ():
692+ """
693+ We are allowed to add panels in GeoPlots
694+ """
695+ # Define coordinates
696+ lat = np .linspace (- 90 , 90 , 180 )
697+ lon = np .linspace (- 180 , 180 , 360 )
698+ time = np .arange (2000 , 2005 )
699+ lon_grid , lat_grid = np .meshgrid (lon , lat )
700+
701+ # Zoomed region elevation (Asia region)
702+ lat_zoom = np .linspace (0 , 60 , 60 )
703+ lon_zoom = np .linspace (60 , 180 , 120 )
704+ lz , lz_grid = np .meshgrid (lon_zoom , lat_zoom )
705+
706+ elevation = (
707+ 2000 * np .exp (- ((lz - 90 ) ** 2 + (lz_grid - 30 ) ** 2 ) / 400 )
708+ + 1000 * np .exp (- ((lz - 120 ) ** 2 + (lz_grid - 45 ) ** 2 ) / 225 )
709+ + np .random .normal (0 , 100 , lz .shape )
710+ )
711+ elevation = np .clip (elevation , 0 , 4000 )
712+
713+ fig , ax = uplt .subplots (nrows = 2 , proj = "cyl" )
714+ pax = ax [0 ].panel ("r" )
715+ pax .barh (lat_zoom , elevation .sum (axis = 1 ))
716+ pax = ax [1 ].panel ("r" )
717+ pax .barh (lat_zoom - 30 , elevation .sum (axis = 1 ))
718+ ax [0 ].pcolormesh (
719+ lon_zoom ,
720+ lat_zoom ,
721+ elevation ,
722+ cmap = "bilbao" ,
723+ colorbar = "t" ,
724+ colorbar_kw = dict (
725+ align = "l" ,
726+ length = 0.5 ,
727+ ),
728+ )
729+ ax [1 ].pcolormesh (
730+ lon_zoom ,
731+ lat_zoom - 30 ,
732+ elevation ,
733+ cmap = "glacial" ,
734+ colorbar = "t" ,
735+ colorbar_kw = dict (
736+ align = "r" ,
737+ length = 0.5 ,
738+ ),
739+ )
740+ ax .format (oceancolor = "blue" , coast = True )
741+ return fig
0 commit comments