@@ -73,7 +73,7 @@ def test_replaceDataWithNaN():
73
73
74
74
with plt .rc_context (rc = RC_PARAMS ):
75
75
fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
76
- l , = ax .plot (xData , yData )
76
+ ( l ,) = ax .plot (xData , yData )
77
77
78
78
cleanfigure ._replaceDataWithNan (l , id_replace )
79
79
@@ -106,7 +106,7 @@ def test_removeData():
106
106
107
107
with plt .rc_context (rc = RC_PARAMS ):
108
108
fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
109
- l , = ax .plot (xData , yData )
109
+ ( l ,) = ax .plot (xData , yData )
110
110
111
111
cleanfigure ._removeData (l , id_remove )
112
112
newdata = np .stack (l .get_data (), axis = 1 )
@@ -138,7 +138,7 @@ def test_removeNaNs():
138
138
139
139
with plt .rc_context (rc = RC_PARAMS ):
140
140
fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
141
- l , = ax .plot (xData , yData )
141
+ ( l ,) = ax .plot (xData , yData )
142
142
cleanfigure ._replaceDataWithNan (l , id_replace )
143
143
cleanfigure ._removeData (l , id_remove )
144
144
cleanfigure ._removeNaNs (l )
@@ -292,7 +292,7 @@ def test_simplifyLine():
292
292
# cleanfigure;
293
293
# ```
294
294
# """
295
- # # TODO: it looks like matlab changes the data to be plotted when using `stairs` command,
295
+ # # TODO: it looks like matlab changes the data to be plotted when using `stairs` command,
296
296
# # whereas matplotlib stores the same data but displays it as a step.
297
297
# x = np.linspace(1, 100, 20)
298
298
# y = np.linspace(1, 100, 20)
@@ -492,15 +492,16 @@ def test_hist(self):
492
492
def test_plot3d (self ):
493
493
""" """
494
494
from mpl_toolkits .mplot3d import Axes3D
495
+
495
496
theta = np .linspace (- 4 * np .pi , 4 * np .pi , 100 )
496
497
z = np .linspace (- 2 , 2 , 100 )
497
- r = z ** 2 + 1
498
+ r = z ** 2 + 1
498
499
x = r * np .sin (theta )
499
500
y = r * np .cos (theta )
500
501
501
502
with plt .rc_context (rc = RC_PARAMS ):
502
503
fig = plt .figure ()
503
- ax = fig .add_subplot (111 , projection = '3d' )
504
+ ax = fig .add_subplot (111 , projection = "3d" )
504
505
ax .plot (x , y , z )
505
506
ax .set_xlim ([- 2 , 2 ])
506
507
ax .set_ylim ([- 2 , 2 ])
@@ -525,7 +526,7 @@ def test_scatter3d(self):
525
526
526
527
with plt .rc_context (rc = RC_PARAMS ):
527
528
fig = plt .figure ()
528
- ax = fig .add_subplot (111 , projection = '3d' )
529
+ ax = fig .add_subplot (111 , projection = "3d" )
529
530
ax .scatter (x , y , z )
530
531
ax .set_xlim ([20 , 80 ])
531
532
ax .set_ylim ([20 , 80 ])
@@ -536,12 +537,13 @@ def test_scatter3d(self):
536
537
def test_wireframe3D (self ):
537
538
""" """
538
539
from mpl_toolkits .mplot3d import axes3d
540
+
539
541
# Grab some test data.
540
542
X , Y , Z = axes3d .get_test_data (0.05 )
541
543
542
544
with plt .rc_context (rc = RC_PARAMS ):
543
545
fig = plt .figure ()
544
- ax = fig .add_subplot (111 , projection = '3d' )
546
+ ax = fig .add_subplot (111 , projection = "3d" )
545
547
546
548
# Plot a basic wireframe.
547
549
ax .plot_wireframe (X , Y , Z , rstride = 10 , cstride = 10 )
@@ -553,25 +555,27 @@ def test_surface3D(self):
553
555
from mpl_toolkits .mplot3d import Axes3D
554
556
from matplotlib import cm
555
557
from matplotlib .ticker import LinearLocator , FormatStrFormatter
558
+
556
559
# Make data.
557
560
X = np .arange (- 5 , 5 , 0.25 )
558
561
Y = np .arange (- 5 , 5 , 0.25 )
559
562
X , Y = np .meshgrid (X , Y )
560
- R = np .sqrt (X ** 2 + Y ** 2 )
563
+ R = np .sqrt (X ** 2 + Y ** 2 )
561
564
Z = np .sin (R )
562
565
563
566
with plt .rc_context (rc = RC_PARAMS ):
564
567
fig = plt .figure ()
565
- ax = fig .gca (projection = '3d' )
568
+ ax = fig .gca (projection = "3d" )
566
569
567
570
# Plot the surface.
568
- surf = ax .plot_surface (X , Y , Z , cmap = cm .coolwarm ,
569
- linewidth = 0 , antialiased = False )
571
+ surf = ax .plot_surface (
572
+ X , Y , Z , cmap = cm .coolwarm , linewidth = 0 , antialiased = False
573
+ )
570
574
571
575
# Customize the z axis.
572
576
ax .set_zlim (- 1.01 , 1.01 )
573
577
ax .zaxis .set_major_locator (LinearLocator (10 ))
574
- ax .zaxis .set_major_formatter (FormatStrFormatter (' %.02f' ))
578
+ ax .zaxis .set_major_formatter (FormatStrFormatter (" %.02f" ))
575
579
576
580
# Add a color bar which maps values to colors.
577
581
fig .colorbar (surf , shrink = 0.5 , aspect = 5 )
@@ -593,24 +597,23 @@ def test_trisurface3D(Self):
593
597
n_angles = 36
594
598
# Make radii and angles spaces (radius r=0 omitted to eliminate duplication).
595
599
radii = np .linspace (0.125 , 1.0 , n_radii )
596
- angles = np .linspace (0 , 2 * np .pi , n_angles , endpoint = False )
600
+ angles = np .linspace (0 , 2 * np .pi , n_angles , endpoint = False )
597
601
598
602
# Repeat all angles for each radius.
599
603
angles = np .repeat (angles [..., np .newaxis ], n_radii , axis = 1 )
600
604
601
605
# Convert polar (radii, angles) coords to cartesian (x, y) coords.
602
606
# (0, 0) is manually added at this stage, so there will be no duplicate
603
607
# points in the (x, y) plane.
604
- x = np .append (0 , (radii * np .cos (angles )).flatten ())
605
- y = np .append (0 , (radii * np .sin (angles )).flatten ())
608
+ x = np .append (0 , (radii * np .cos (angles )).flatten ())
609
+ y = np .append (0 , (radii * np .sin (angles )).flatten ())
606
610
607
611
# Compute z to make the pringle surface.
608
- z = np .sin (- x * y )
609
-
612
+ z = np .sin (- x * y )
610
613
611
614
with plt .rc_context (rc = RC_PARAMS ):
612
615
fig = plt .figure ()
613
- ax = fig .gca (projection = '3d' )
616
+ ax = fig .gca (projection = "3d" )
614
617
615
618
ax .plot_trisurf (x , y , z , linewidth = 0.2 , antialiased = True )
616
619
with pytest .warns (Warning ):
@@ -624,13 +627,13 @@ def test_contour3D(self):
624
627
625
628
with plt .rc_context (rc = RC_PARAMS ):
626
629
fig = plt .figure ()
627
- ax = fig .add_subplot (111 , projection = '3d' )
630
+ ax = fig .add_subplot (111 , projection = "3d" )
628
631
X , Y , Z = axes3d .get_test_data (0.05 )
629
632
cset = ax .contour (X , Y , Z , cmap = cm .coolwarm )
630
633
ax .clabel (cset , fontsize = 9 , inline = 1 )
631
634
with pytest .warns (Warning ):
632
635
cleanfigure .cleanfigure (fig )
633
-
636
+
634
637
def test_polygon3D (self ):
635
638
""" """
636
639
from mpl_toolkits .mplot3d import Axes3D
@@ -639,7 +642,7 @@ def test_polygon3D(self):
639
642
640
643
with plt .rc_context (rc = RC_PARAMS ):
641
644
fig = plt .figure ()
642
- ax = fig .gca (projection = '3d' )
645
+ ax = fig .gca (projection = "3d" )
643
646
644
647
def cc (arg ):
645
648
"""
@@ -657,16 +660,17 @@ def cc(arg):
657
660
ys [0 ], ys [- 1 ] = 0 , 0
658
661
verts .append (list (zip (xs , ys )))
659
662
660
- poly = PolyCollection (verts , facecolors = [cc ('r' ), cc ('g' ), cc ('b' ),
661
- cc ('y' )])
663
+ poly = PolyCollection (
664
+ verts , facecolors = [cc ("r" ), cc ("g" ), cc ("b" ), cc ("y" )]
665
+ )
662
666
poly .set_alpha (0.7 )
663
- ax .add_collection3d (poly , zs = zs , zdir = 'y' )
667
+ ax .add_collection3d (poly , zs = zs , zdir = "y" )
664
668
665
- ax .set_xlabel ('X' )
669
+ ax .set_xlabel ("X" )
666
670
ax .set_xlim3d (0 , 10 )
667
- ax .set_ylabel ('Y' )
671
+ ax .set_ylabel ("Y" )
668
672
ax .set_ylim3d (- 1 , 4 )
669
- ax .set_zlabel ('Z' )
673
+ ax .set_zlabel ("Z" )
670
674
ax .set_zlim3d (0 , 1 )
671
675
with pytest .warns (Warning ):
672
676
cleanfigure .cleanfigure (fig )
@@ -677,23 +681,22 @@ def test_bar3D(self):
677
681
import matplotlib .pyplot as plt
678
682
import numpy as np
679
683
680
-
681
684
with plt .rc_context (rc = RC_PARAMS ):
682
685
fig = plt .figure ()
683
- ax = fig .add_subplot (111 , projection = '3d' )
684
- for c , z in zip (['r' , 'g' , 'b' , 'y' ], [30 , 20 , 10 , 0 ]):
686
+ ax = fig .add_subplot (111 , projection = "3d" )
687
+ for c , z in zip (["r" , "g" , "b" , "y" ], [30 , 20 , 10 , 0 ]):
685
688
xs = np .arange (20 )
686
689
ys = np .random .rand (20 )
687
690
688
691
# You can provide either a single color or an array. To demonstrate this,
689
692
# the first bar of each set will be colored cyan.
690
693
cs = [c ] * len (xs )
691
- cs [0 ] = 'c'
692
- ax .bar (xs , ys , zs = z , zdir = 'y' , color = cs , alpha = 0.8 )
694
+ cs [0 ] = "c"
695
+ ax .bar (xs , ys , zs = z , zdir = "y" , color = cs , alpha = 0.8 )
693
696
694
- ax .set_xlabel ('X' )
695
- ax .set_ylabel ('Y' )
696
- ax .set_zlabel ('Z' )
697
+ ax .set_xlabel ("X" )
698
+ ax .set_ylabel ("Y" )
699
+ ax .set_zlabel ("Z" )
697
700
with pytest .warns (Warning ):
698
701
cleanfigure .cleanfigure (fig )
699
702
@@ -703,21 +706,26 @@ def test_quiver3D(self):
703
706
import matplotlib .pyplot as plt
704
707
import numpy as np
705
708
706
-
707
709
with plt .rc_context (rc = RC_PARAMS ):
708
710
fig = plt .figure ()
709
- ax = fig .gca (projection = '3d' )
711
+ ax = fig .gca (projection = "3d" )
710
712
711
713
# Make the grid
712
- x , y , z = np .meshgrid (np .arange (- 0.8 , 1 , 0.2 ),
713
- np .arange (- 0.8 , 1 , 0.2 ),
714
- np .arange (- 0.8 , 1 , 0.8 ))
714
+ x , y , z = np .meshgrid (
715
+ np .arange (- 0.8 , 1 , 0.2 ),
716
+ np .arange (- 0.8 , 1 , 0.2 ),
717
+ np .arange (- 0.8 , 1 , 0.8 ),
718
+ )
715
719
716
720
# Make the direction data for the arrows
717
721
u = np .sin (np .pi * x ) * np .cos (np .pi * y ) * np .cos (np .pi * z )
718
722
v = - np .cos (np .pi * x ) * np .sin (np .pi * y ) * np .cos (np .pi * z )
719
- w = (np .sqrt (2.0 / 3.0 ) * np .cos (np .pi * x ) * np .cos (np .pi * y ) *
720
- np .sin (np .pi * z ))
723
+ w = (
724
+ np .sqrt (2.0 / 3.0 )
725
+ * np .cos (np .pi * x )
726
+ * np .cos (np .pi * y )
727
+ * np .sin (np .pi * z )
728
+ )
721
729
722
730
ax .quiver (x , y , z , u , v , w , length = 0.1 , normalize = True )
723
731
with pytest .warns (Warning ):
@@ -731,42 +739,43 @@ def test_2D_in_3D(self):
731
739
732
740
with plt .rc_context (rc = RC_PARAMS ):
733
741
fig = plt .figure ()
734
- ax = fig .gca (projection = '3d' )
742
+ ax = fig .gca (projection = "3d" )
735
743
736
744
# Plot a sin curve using the x and y axes.
737
745
x = np .linspace (0 , 1 , 100 )
738
746
y = np .sin (x * 2 * np .pi ) / 2 + 0.5
739
- ax .plot (x , y , zs = 0 , zdir = 'z' , label = ' curve in (x,y)' )
747
+ ax .plot (x , y , zs = 0 , zdir = "z" , label = " curve in (x,y)" )
740
748
741
749
# Plot scatterplot data (20 2D points per colour) on the x and z axes.
742
- colors = ('r' , 'g' , 'b' , 'k' )
743
- x = np .random .sample (20 * len (colors ))
744
- y = np .random .sample (20 * len (colors ))
750
+ colors = ("r" , "g" , "b" , "k" )
751
+ x = np .random .sample (20 * len (colors ))
752
+ y = np .random .sample (20 * len (colors ))
745
753
c_list = []
746
754
for c in colors :
747
- c_list += [c ]* 20
755
+ c_list += [c ] * 20
748
756
# By using zdir='y', the y value of these points is fixed to the zs value 0
749
757
# and the (x,y) points are plotted on the x and z axes.
750
- ax .scatter (x , y , zs = 0 , zdir = 'y' , c = c_list , label = ' points in (x,z)' )
758
+ ax .scatter (x , y , zs = 0 , zdir = "y" , c = c_list , label = " points in (x,z)" )
751
759
752
760
# Make legend, set axes limits and labels
753
761
ax .legend ()
754
762
ax .set_xlim (0 , 1 )
755
763
ax .set_ylim (0 , 1 )
756
764
ax .set_zlim (0 , 1 )
757
- ax .set_xlabel ('X' )
758
- ax .set_ylabel ('Y' )
759
- ax .set_zlabel ('Z' )
765
+ ax .set_xlabel ("X" )
766
+ ax .set_ylabel ("Y" )
767
+ ax .set_zlabel ("Z" )
760
768
761
769
# Customize the view angle so it's easier to see that the scatter points lie
762
770
# on the plane y=0
763
- ax .view_init (elev = 20. , azim = - 35 )
771
+ ax .view_init (elev = 20.0 , azim = - 35 )
764
772
with pytest .warns (Warning ):
765
773
cleanfigure .cleanfigure (fig )
766
774
767
775
768
776
class Test_lineplot :
769
777
""" """
778
+
770
779
def test_line_no_markers (self ):
771
780
"""test high-level usage for simple example.
772
781
Test is successfull if generated tikz code saves correct amount of lines
@@ -878,6 +887,7 @@ def test_sine(self):
878
887
879
888
class Test_subplots :
880
889
""" """
890
+
881
891
def test_subplot (self ):
882
892
"""octave code
883
893
0 commit comments