ソースを参照

Some tweaking of axis limits

tforest 2 ヶ月 前
コミット
0ffb02e511
共有1 個のファイルを変更した24 個の追加5 個の削除を含む
  1. 24 5
      swp2.py

+ 24 - 5
swp2.py ファイルの表示

483
         if subset is not None:
483
         if subset is not None:
484
             if breaks in subset:
484
             if breaks in subset:
485
                 masking_alpha = 0.75
485
                 masking_alpha = 0.75
486
+                autoscale = True
486
             else:
487
             else:
487
                 masking_alpha = 0
488
                 masking_alpha = 0
489
+                autoscale = False
490
+        ax2.set_autoscale_on(autoscale)
491
+        ax3.set_autoscale_on(autoscale)
488
         p2, = ax2.plot(x2_plot, y2_plot, 'o', linestyle="-", alpha=masking_alpha, lw=2, label = str(breaks)+' brks')
492
         p2, = ax2.plot(x2_plot, y2_plot, 'o', linestyle="-", alpha=masking_alpha, lw=2, label = str(breaks)+' brks')
489
         # Plotting (fig 3) which is the same but log scale for x
493
         # Plotting (fig 3) which is the same but log scale for x
490
         p3, = ax3.plot(x2_plot, y2_plot, 'o', linestyle="-", alpha=masking_alpha, lw=2, label = str(breaks)+' brks')
494
         p3, = ax3.plot(x2_plot, y2_plot, 'o', linestyle="-", alpha=masking_alpha, lw=2, label = str(breaks)+' brks')
497
         xlabel = "Theta scaled by N0"
501
         xlabel = "Theta scaled by N0"
498
         ylabel = "Theta scaled by N0"
502
         ylabel = "Theta scaled by N0"
499
     else:
503
     else:
500
-        xlabel = "t"
501
-        ylabel = r"$\theta$"
504
+        xlabel = "time"
505
+        ylabel = "Effective pop. size (Ne)"
502
     if ax is None:
506
     if ax is None:
503
         # if not ax, then use the plt syntax, not ax...
507
         # if not ax, then use the plt syntax, not ax...
504
         plt.xlabel(xlabel, fontsize=fnt_size)
508
         plt.xlabel(xlabel, fontsize=fnt_size)
505
         plt.ylabel(ylabel, fontsize=fnt_size)
509
         plt.ylabel(ylabel, fontsize=fnt_size)
506
         plt.xlim(left=0)
510
         plt.xlim(left=0)
511
+        xlim_val = plt.gca().get_xlim()
507
         x_ticks = list(plt.xticks())[0]
512
         x_ticks = list(plt.xticks())[0]
508
         plt.gca().set_xticks(x_ticks)
513
         plt.gca().set_xticks(x_ticks)
514
+        plt.gca().set_xlim(xlim_val)
509
         plt.gca().set_xticklabels([f'{k:.0e}\n{k/(mu):.0e}\n{k/(mu)*tgen:.0e}' for k in x_ticks], fontsize = fnt_size*0.5)
515
         plt.gca().set_xticklabels([f'{k:.0e}\n{k/(mu):.0e}\n{k/(mu)*tgen:.0e}' for k in x_ticks], fontsize = fnt_size*0.5)
516
+        # rescale y to effective pop size
517
+        ylim_val = plt.gca().get_ylim()
518
+        y_ticks = list(plt.yticks())[0]
519
+        plt.gca().set_yticks(y_ticks)
520
+        plt.gca().set_ylim(ylim_val)
521
+        plt.gca().set_yticklabels([f'{k/(4*mu):.0e}' for k in y_ticks], fontsize = fnt_size*0.5)
510
         plt.title(title, fontsize=fnt_size)
522
         plt.title(title, fontsize=fnt_size)
511
         plt.legend(handles=lines_fig2, loc='best', fontsize = fnt_size*0.5)
523
         plt.legend(handles=lines_fig2, loc='best', fontsize = fnt_size*0.5)
512
         plt.text(-0.13, -0.135, 'Coal. time\nGen. time\nYears', ha='left', va='bottom', transform=ax3.transAxes)
524
         plt.text(-0.13, -0.135, 'Coal. time\nGen. time\nYears', ha='left', va='bottom', transform=ax3.transAxes)
522
         ax2.legend(handles=lines_fig2, loc='best', fontsize = fnt_size*0.5)
534
         ax2.legend(handles=lines_fig2, loc='best', fontsize = fnt_size*0.5)
523
     ax3.set_xscale('log')
535
     ax3.set_xscale('log')
524
     ax3.set_yscale('log')
536
     ax3.set_yscale('log')
525
-    ax3.set_xlabel("time log scale", fontsize=fnt_size)
526
-    ax3.set_ylabel("theta", fontsize=fnt_size)
537
+    ax3.set_xlabel(xlabel, fontsize=fnt_size)
538
+    ax3.set_ylabel(ylabel, fontsize=fnt_size)
527
     ax3.set_title(title, fontsize=fnt_size)
539
     ax3.set_title(title, fontsize=fnt_size)
528
     ax3.legend(handles=lines_fig3, loc='best', fontsize = fnt_size*0.5)
540
     ax3.legend(handles=lines_fig3, loc='best', fontsize = fnt_size*0.5)
541
+    xlim_val = ax3.get_xlim()
529
     x_ticks = list(ax3.get_xticks())
542
     x_ticks = list(ax3.get_xticks())
530
-    ax3.set_xlim(left=min(x_ticks))
531
     ax3.set_xticks(x_ticks)
543
     ax3.set_xticks(x_ticks)
544
+    ax3.set_xlim(xlim_val)
532
     ax3.set_xticklabels([f'{k:.0e}\n{k/(mu):.0e}\n{k/(mu)*tgen:.0e}' for k in x_ticks], fontsize = fnt_size*0.5)
545
     ax3.set_xticklabels([f'{k:.0e}\n{k/(mu):.0e}\n{k/(mu)*tgen:.0e}' for k in x_ticks], fontsize = fnt_size*0.5)
546
+    ylim_val = ax3.get_ylim()
547
+    # rescale y to effective pop size
548
+    y_ticks = list(ax3.get_yticks())
549
+    ax3.set_yticks(y_ticks)
550
+    ax3.set_ylim(ylim_val)
551
+    ax3.set_yticklabels([f'{k/(4*mu):.0e}' for k in y_ticks], fontsize = fnt_size*0.5)
533
     plt.text(-0.13, -0.135, 'Coal. time\nGen. time\nYears', ha='left', va='bottom', transform=ax3.transAxes)
552
     plt.text(-0.13, -0.135, 'Coal. time\nGen. time\nYears', ha='left', va='bottom', transform=ax3.transAxes)
534
     plt.subplots_adjust(bottom=0.2)  # Adjust the value as needed
553
     plt.subplots_adjust(bottom=0.2)  # Adjust the value as needed
535
     if ax is None:
554
     if ax is None: