@@ -542,179 +542,3 @@ def floatingaxes_class_factory(axes_class):
542
542
543
543
import matplotlib .axes as maxes
544
544
FloatingSubplot = maxes .subplot_class_factory (FloatingAxes )
545
-
546
- # def test(fig):
547
- # from mpl_toolkits.axes_grid.axislines import Subplot
548
- # ax = Subplot(fig, 111)
549
-
550
- # fig.add_subplot(ax)
551
-
552
- # plt.draw()
553
-
554
-
555
- def curvelinear_test3 (fig ):
556
- """
557
- polar projection, but in a rectangular box.
558
- """
559
- global ax1 , axis
560
- import numpy as np
561
- from . import angle_helper
562
- from matplotlib .projections import PolarAxes
563
-
564
- # PolarAxes.PolarTransform takes radian. However, we want our coordinate
565
- # system in degree
566
- tr = Affine2D ().scale (np .pi / 180. , 1. ) + PolarAxes .PolarTransform ()
567
-
568
- # polar projection, which involves cycle, and also has limits in
569
- # its coordinates, needs a special method to find the extremes
570
- # (min, max of the coordinate within the view).
571
-
572
-
573
- grid_locator1 = angle_helper .LocatorDMS (15 )
574
- # Find a grid values appropriate for the coordinate (degree,
575
- # minute, second).
576
-
577
- tick_formatter1 = angle_helper .FormatterDMS ()
578
- # And also uses an appropriate formatter. Note that,the
579
- # acceptable Locator and Formatter class is a bit different than
580
- # that of mpl's, and you cannot directly use mpl's Locator and
581
- # Formatter here (but may be possible in the future).
582
-
583
- from .grid_finder import FixedLocator
584
- grid_locator2 = FixedLocator ([2 , 4 , 6 , 8 , 10 ])
585
-
586
-
587
- grid_helper = GridHelperCurveLinear (tr ,
588
- extremes = (0 , 360 , 10 , 3 ),
589
- grid_locator1 = grid_locator1 ,
590
- grid_locator2 = grid_locator2 ,
591
- tick_formatter1 = tick_formatter1 ,
592
- tick_formatter2 = None ,
593
- )
594
-
595
- ax1 = FloatingSubplot (fig , 111 , grid_helper = grid_helper )
596
-
597
-
598
- #ax1.axis["top"].set_visible(False)
599
- #ax1.axis["bottom"].major_ticklabels.set_axis_direction("top")
600
-
601
- fig .add_subplot (ax1 )
602
-
603
-
604
- #ax1.grid(True)
605
-
606
-
607
- r_scale = 10.
608
- tr2 = Affine2D ().scale (1. , 1. / r_scale ) + tr
609
- grid_locator2 = FixedLocator ([30 , 60 , 90 ])
610
- grid_helper2 = GridHelperCurveLinear (tr2 ,
611
- extremes = (0 , 360 ,
612
- 10. * r_scale , 3. * r_scale ),
613
- grid_locator2 = grid_locator2 ,
614
- )
615
-
616
- ax1 .axis ["right" ] = axis = grid_helper2 .new_fixed_axis ("right" , axes = ax1 )
617
-
618
- ax1 .axis ["left" ].label .set_text ("Test 1" )
619
- ax1 .axis ["right" ].label .set_text ("Test 2" )
620
-
621
-
622
- for an in [ "left" , "right" ]:
623
- ax1 .axis [an ].set_visible (False )
624
-
625
-
626
- #grid_helper2 = ax1.get_grid_helper()
627
- ax1 .axis ["z" ] = axis = grid_helper .new_floating_axis (1 , 7 ,
628
- axes = ax1 ,
629
- axis_direction = "bottom" )
630
- axis .toggle (all = True , label = True )
631
- #axis.label.set_axis_direction("top")
632
- axis .label .set_text ("z = ?" )
633
- axis .label .set_visible (True )
634
- axis .line .set_color ("0.5" )
635
- #axis.label.set_visible(True)
636
-
637
-
638
- ax2 = ax1 .get_aux_axes (tr )
639
-
640
- xx , yy = [67 , 90 , 75 , 30 ], [2 , 5 , 8 , 4 ]
641
- ax2 .scatter (xx , yy )
642
- l , = ax2 .plot (xx , yy , "k-" )
643
- l .set_clip_path (ax1 .patch )
644
-
645
-
646
- def curvelinear_test4 (fig ):
647
- """
648
- polar projection, but in a rectangular box.
649
- """
650
- global ax1 , axis
651
- import numpy as np
652
- from . import angle_helper
653
- from matplotlib .projections import PolarAxes
654
-
655
- tr = Affine2D ().scale (np .pi / 180. , 1. ) + PolarAxes .PolarTransform ()
656
-
657
- grid_locator1 = angle_helper .LocatorDMS (5 )
658
- tick_formatter1 = angle_helper .FormatterDMS ()
659
-
660
- from .grid_finder import FixedLocator
661
- grid_locator2 = FixedLocator ([2 , 4 , 6 , 8 , 10 ])
662
-
663
- grid_helper = GridHelperCurveLinear (tr ,
664
- extremes = (120 , 30 , 10 , 0 ),
665
- grid_locator1 = grid_locator1 ,
666
- grid_locator2 = grid_locator2 ,
667
- tick_formatter1 = tick_formatter1 ,
668
- tick_formatter2 = None ,
669
- )
670
-
671
- ax1 = FloatingSubplot (fig , 111 , grid_helper = grid_helper )
672
-
673
-
674
- #ax1.axis["top"].set_visible(False)
675
- #ax1.axis["bottom"].major_ticklabels.set_axis_direction("top")
676
-
677
- fig .add_subplot (ax1 )
678
-
679
-
680
- #ax1.grid(True)
681
-
682
-
683
- ax1 .axis ["left" ].label .set_text ("Test 1" )
684
- ax1 .axis ["right" ].label .set_text ("Test 2" )
685
-
686
-
687
- for an in [ "top" ]:
688
- ax1 .axis [an ].set_visible (False )
689
-
690
-
691
- #grid_helper2 = ax1.get_grid_helper()
692
- ax1 .axis ["z" ] = axis = grid_helper .new_floating_axis (1 , 70 ,
693
- axes = ax1 ,
694
- axis_direction = "bottom" )
695
- axis .toggle (all = True , label = True )
696
- axis .label .set_axis_direction ("top" )
697
- axis .label .set_text ("z = ?" )
698
- axis .label .set_visible (True )
699
- axis .line .set_color ("0.5" )
700
- #axis.label.set_visible(True)
701
-
702
-
703
- ax2 = ax1 .get_aux_axes (tr )
704
-
705
- xx , yy = [67 , 90 , 75 , 30 ], [2 , 5 , 8 , 4 ]
706
- ax2 .scatter (xx , yy )
707
- l , = ax2 .plot (xx , yy , "k-" )
708
- l .set_clip_path (ax1 .patch )
709
-
710
- if __name__ == "__main__" :
711
- import matplotlib .pyplot as plt
712
- fig = plt .figure (1 , figsize = (5 , 5 ))
713
- fig .clf ()
714
-
715
- #test(fig)
716
- #curvelinear_test1(fig)
717
- curvelinear_test4 (fig )
718
-
719
- #plt.draw()
720
- plt .show ()
0 commit comments