@@ -33,45 +33,6 @@ def test_plot(self):
33
33
assert numLinesRaw - numLinesClean == 18
34
34
plt .close ("all" )
35
35
36
- def test_logplot (self ):
37
- x = np .logspace (- 3 , 3 , 20 )
38
- y = np .logspace (- 3 , 3 , 20 )
39
-
40
- with plt .rc_context (rc = RC_PARAMS ):
41
- fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
42
- ax .plot (x , y )
43
- ax .set_xscale ("log" )
44
- ax .set_yscale ("log" )
45
- ax .set_ylim ([10 ** (- 2 ), 10 ** (2 )])
46
- ax .set_xlim ([10 ** (- 2 ), 10 ** (2 )])
47
- raw = get_tikz_code ()
48
-
49
- clean_figure (fig )
50
- clean = get_tikz_code ()
51
- numLinesRaw = raw .count ("\n " )
52
- numLinesClean = clean .count ("\n " )
53
- assert numLinesRaw - numLinesClean == 11
54
- plt .close ("all" )
55
-
56
- def test_semilogplot (self ):
57
- x = np .logspace (- 3 , 3 , 20 )
58
- y = np .linspace (1 , 100 , 20 )
59
-
60
- with plt .rc_context (rc = RC_PARAMS ):
61
- fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
62
- ax .plot (x , y )
63
- ax .set_xscale ("log" )
64
- ax .set_xlim ([10 ** (- 2 ), 10 ** (2 )])
65
- ax .set_ylim ([20 , 80 ])
66
- raw = get_tikz_code ()
67
-
68
- clean_figure (fig )
69
- clean = get_tikz_code ()
70
- numLinesRaw = raw .count ("\n " )
71
- numLinesClean = clean .count ("\n " )
72
- assert numLinesRaw - numLinesClean == 6
73
- plt .close ("all" )
74
-
75
36
def test_step (self ):
76
37
x = np .linspace (1 , 100 , 20 )
77
38
y = np .linspace (1 , 100 , 20 )
@@ -556,6 +517,154 @@ def test_subplot(self):
556
517
plt .close ("all" )
557
518
558
519
520
+ class Test_logscale :
521
+ def test_ylog (self ):
522
+ x = np .linspace (0 , 3 , 100 )
523
+ y = np .exp (x )
524
+
525
+ with plt .rc_context (rc = RC_PARAMS ):
526
+ fig , ax = plt .subplots (1 )
527
+ ax .plot (x , y )
528
+ ax .set_yscale ("log" )
529
+ raw = get_tikz_code ()
530
+ clean_figure ()
531
+
532
+ clean = get_tikz_code ()
533
+ numLinesRaw = raw .count ("\n " )
534
+ numLinesClean = clean .count ("\n " )
535
+ assert numLinesRaw - numLinesClean == 98
536
+ assert numLinesClean == 25
537
+ plt .close ("all" )
538
+
539
+ def test_xlog (self ):
540
+ y = np .linspace (0 , 3 , 100 )
541
+ x = np .exp (y )
542
+
543
+ with plt .rc_context (rc = RC_PARAMS ):
544
+ fig , ax = plt .subplots (1 )
545
+ ax .plot (x , y )
546
+ ax .set_xscale ("log" )
547
+ raw = get_tikz_code ()
548
+ clean_figure ()
549
+
550
+ clean = get_tikz_code ()
551
+ numLinesRaw = raw .count ("\n " )
552
+ numLinesClean = clean .count ("\n " )
553
+ assert numLinesRaw - numLinesClean == 98
554
+ assert numLinesClean == 25
555
+ plt .close ("all" )
556
+
557
+ def test_loglog (self ):
558
+ x = np .exp (np .logspace (0 , 5 , 100 ))
559
+ y = np .exp (np .logspace (0 , 5 , 100 ))
560
+
561
+ with plt .rc_context (rc = RC_PARAMS ):
562
+ fig , ax = plt .subplots (1 )
563
+ ax .plot (x , y )
564
+ ax .set_xscale ("log" )
565
+ ax .set_yscale ("log" )
566
+ raw = get_tikz_code ()
567
+ clean_figure ()
568
+
569
+ clean = get_tikz_code ()
570
+ numLinesRaw = raw .count ("\n " )
571
+ numLinesClean = clean .count ("\n " )
572
+ assert numLinesRaw - numLinesClean == 98
573
+ assert numLinesClean == 27
574
+ plt .close ("all" )
575
+
576
+ def test_ylog_2 (self ):
577
+ x = np .arange (1 , 100 )
578
+ y = np .arange (1 , 100 )
579
+ with plt .rc_context (rc = RC_PARAMS ):
580
+ fig , ax = plt .subplots (1 )
581
+ ax .plot (x , y )
582
+ ax .set_yscale ("log" )
583
+ raw = get_tikz_code ()
584
+ clean_figure ()
585
+
586
+ clean = get_tikz_code ()
587
+ numLinesRaw = raw .count ("\n " )
588
+ numLinesClean = clean .count ("\n " )
589
+ assert numLinesRaw - numLinesClean == 51
590
+ assert numLinesClean == 71
591
+ plt .close ("all" )
592
+
593
+ def test_xlog_2 (self ):
594
+ x = np .arange (1 , 100 )
595
+ y = np .arange (1 , 100 )
596
+ with plt .rc_context (rc = RC_PARAMS ):
597
+ fig , ax = plt .subplots (1 )
598
+ ax .plot (x , y )
599
+ ax .set_xscale ("log" )
600
+ raw = get_tikz_code ()
601
+ clean_figure ()
602
+
603
+ clean = get_tikz_code ()
604
+ numLinesRaw = raw .count ("\n " )
605
+ numLinesClean = clean .count ("\n " )
606
+ assert numLinesRaw - numLinesClean == 51
607
+ assert numLinesClean == 71
608
+ plt .close ("all" )
609
+
610
+ def test_loglog_2 (self ):
611
+ x = np .arange (1 , 100 )
612
+ y = np .arange (1 , 100 )
613
+ with plt .rc_context (rc = RC_PARAMS ):
614
+ fig , ax = plt .subplots (1 )
615
+ ax .plot (x , y )
616
+ ax .set_xscale ("log" )
617
+ ax .set_yscale ("log" )
618
+ raw = get_tikz_code ()
619
+ clean_figure ()
620
+
621
+ clean = get_tikz_code ()
622
+ numLinesRaw = raw .count ("\n " )
623
+ numLinesClean = clean .count ("\n " )
624
+ assert numLinesRaw - numLinesClean == 97
625
+ assert numLinesClean == 27
626
+ plt .close ("all" )
627
+
628
+ def test_loglog_3 (self ):
629
+ x = np .logspace (- 3 , 3 , 20 )
630
+ y = np .logspace (- 3 , 3 , 20 )
631
+
632
+ with plt .rc_context (rc = RC_PARAMS ):
633
+ fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
634
+ ax .plot (x , y )
635
+ ax .set_xscale ("log" )
636
+ ax .set_yscale ("log" )
637
+ ax .set_ylim ([10 ** (- 2 ), 10 ** (2 )])
638
+ ax .set_xlim ([10 ** (- 2 ), 10 ** (2 )])
639
+ raw = get_tikz_code ()
640
+
641
+ clean_figure (fig )
642
+ clean = get_tikz_code ()
643
+ numLinesRaw = raw .count ("\n " )
644
+ numLinesClean = clean .count ("\n " )
645
+ assert numLinesRaw - numLinesClean == 18
646
+ plt .close ("all" )
647
+
648
+ def test_xlog_3 (self ):
649
+ x = np .logspace (- 3 , 3 , 20 )
650
+ y = np .linspace (1 , 100 , 20 )
651
+
652
+ with plt .rc_context (rc = RC_PARAMS ):
653
+ fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
654
+ ax .plot (x , y )
655
+ ax .set_xscale ("log" )
656
+ ax .set_xlim ([10 ** (- 2 ), 10 ** (2 )])
657
+ ax .set_ylim ([20 , 80 ])
658
+ raw = get_tikz_code ()
659
+
660
+ clean_figure (fig )
661
+ clean = get_tikz_code ()
662
+ numLinesRaw = raw .count ("\n " )
663
+ numLinesClean = clean .count ("\n " )
664
+ assert numLinesRaw - numLinesClean == 18
665
+ plt .close ("all" )
666
+
667
+
559
668
def test_memory ():
560
669
plt .plot (np .arange (100000 ))
561
670
clean_figure ()
0 commit comments