Guest User

Untitled

a guest
Jul 19th, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.75 KB | None | 0 0
  1.     def _set_plot(self):
  2.         figure = plt.figure()
  3.         figure.set_size_inches(self._size[0], self._size[1])
  4.         figure.text(0.25, 0.002, self._disclaimer, family="monospace", va="baseline", fontsize=9)
  5.         # ==========================================
  6.         # ==========================================
  7.         # Creating plots grid
  8.         gs = gridspec.GridSpec(3, 3)
  9.         ax1 = figure.add_subplot(gs[0, :])
  10.         ax2 = figure.add_subplot(gs[1, :], sharex=ax1)
  11.         ax3 = figure.add_subplot(gs[2, 0])
  12.         ax4 = figure.add_subplot(gs[2, -1])
  13.         ax5 = figure.add_subplot(gs[2, -2])
  14.         # Set tics visibility
  15.         # plt.setp(ax1.get_xticklabels(), visible=False)
  16.         # ==========================================
  17.         # AX1
  18.         # ==========================================
  19.         ax1.xaxis_date()
  20.         ax2.xaxis_date()
  21.         ax1.xaxis.set_major_formatter(self._time_format)
  22.         ax2.xaxis.set_major_formatter(self._time_format)
  23.         # ==========================================
  24.  
  25.         #  Color and size of Y1 axis ticks and labels
  26.         ax1.set_title(self._title, fontsize=18)
  27.         ax1.set_ylabel(self.variable, color='k', fontsize=14)
  28.         ax1.tick_params(axis='y', colors='k')
  29.         # Tick labels are displayed as numbers  until they reach -100:100 range.
  30.         # Then ticks are displayed as 10 exponential shown above plot corner
  31.         ax1.ticklabel_format(axis='y', style='sci', scilimits=(-2, 2))
  32.         for label in (ax1.get_yticklabels()):
  33.             label.set_fontname('Arial')
  34.             label.set_fontsize(12)
  35.  
  36.         # AX1 grid line setting
  37.         ax1.xaxis.set_minor_locator(AutoMinorLocator())
  38.         ax1.grid(b=True, which='both', color='k')
  39.         ax1.margins(y=0.2)  # gives space between plot edges and data min, max
  40.  
  41.         # ==========================================
  42.         # AX2
  43.         # ==========================================
  44.         ax2.set_ylabel('abs(delta)', color='k', fontsize=14)
  45.         ax2.tick_params(axis='y', colors='k')
  46.         ax2.ticklabel_format(axis='y', style='sci', scilimits=(-2, 2))
  47.         for label in (ax2.get_yticklabels()):
  48.             label.set_fontname('Arial')
  49.             label.set_fontsize(12)
  50.  
  51.         # AX2 grid setting
  52.         ax2.xaxis.set_minor_locator(AutoMinorLocator())
  53.         ax2.grid(b=True, which='both', color='k')
  54.         ax2.margins(y=0.2)
  55.  
  56.         # ==========================================
  57.         # AX3
  58.         # ==========================================
  59.         ax3.set_title('Data histogram')
  60.         ax3.set_ylabel('Frequency', color='k', fontsize=14)
  61.         ax3.set_xlabel("Discrepancy size", fontsize=10)
  62.         ax3.tick_params(axis='y', colors='k')
  63.         ax3.ticklabel_format(axis='x', style='sci', scilimits=(0, 0))
  64.         ax3.ticklabel_format(axis='y', style='sci', scilimits=(-2, 2))
  65.         for label in (ax3.get_yticklabels()):
  66.             label.set_fontname('Arial')
  67.             label.set_fontsize(10)
  68.  
  69.         # AX3 grid setting
  70.         ax3.xaxis.set_minor_locator(AutoMinorLocator())
  71.         ax3.grid(which='major', color='k')
  72.         ax3.margins(y=0.2)
  73.  
  74.         # ==========================================
  75.         # AX4
  76.         # ==========================================
  77.         ax4.set_title('Data Box plot')
  78.         ax4.set_ylabel(self.variable, fontsize=10)
  79.         ax4.tick_params(axis='y', colors='k')
  80.         ax4.ticklabel_format(axis='x', style='sci', scilimits=(0, 0))
  81.         ax4.ticklabel_format(axis='y', style='sci', scilimits=(-2, 2))
  82.         for label in (ax4.get_yticklabels()):
  83.             label.set_fontname('Arial')
  84.             label.set_fontsize(10)
  85.  
  86.         # AX4 grid setting
  87.         ax4.xaxis.set_minor_locator(AutoMinorLocator())
  88.         ax4.grid(which='major', color='k')
  89.         ax4.margins(y=0.2)
  90.  
  91.         # ==========================================
  92.         # AX5
  93.         # ==========================================
  94.         ax5.set_title('abs(delta) histogram')
  95.         ax5.set_xlabel("Discrepancy size", fontsize=11)
  96.         ax5.tick_params(axis='y', colors='k')
  97.         ax5.ticklabel_format(axis='x', style='sci', scilimits=(0, 0))
  98.         ax5.ticklabel_format(axis='y', style='sci', scilimits=(-2, 2))
  99.         for label in (ax5.get_yticklabels()):
  100.             label.set_fontname('Arial')
  101.             label.set_fontsize(10)
  102.  
  103.         # AX5 grid setting
  104.         ax5.xaxis.set_minor_locator(AutoMinorLocator())
  105.         ax5.grid(which='major', color='k')
  106.         ax5.margins(y=0.2)
  107.         # ==========================================
  108.         # ==========================================
  109.  
  110.         # ax1.set_xticklabels([])
  111.         # gs.tight_layout(figure)
  112.         figure.tight_layout()
  113.         return figure, ax1, ax2, ax3, ax4, ax5
Advertisement
Add Comment
Please, Sign In to add comment