Code Duplication    Length = 23-23 lines in 2 locations

examples/meteogram_metpy.py 2 locations

@@ 157-179 (lines=23) @@
154
        axtwin = self.ax3.twinx()
155
        axtwin.set_ylim(plot_range[0], plot_range[1], plot_range[2])
156
157
    def plot_pressure(self, p, plot_range=None):
158
        """
159
        Required input:
160
            P: Mean Sea Level Pressure (hPa)
161
        Optional Input:
162
            plot_range: Data range for making figure (list of (min,max,step))
163
        """
164
        # PLOT PRESSURE
165
        if not plot_range: plot_range = [970, 1030, 2]
166
        self.ax4 = fig.add_subplot(4, 1, 4, sharex=self.ax1)
167
        self.ax4.plot(self.dates,
168
                      p,
169
                      'm',
170
                      label='Mean Sea Level Pressure')
171
        plt.ylabel('Mean Sea\nLevel Pressure\n(mb)', multialignment='center')
172
        plt.ylim(plot_range[0], plot_range[1], plot_range[2])
173
        axtwin = self.ax4.twinx()
174
        axtwin.set_ylim(plot_range[0], plot_range[1], plot_range[2])
175
        plt.fill_between(self.dates, p, plt.ylim()[0], color='m')
176
        plt.gca().xaxis.set_major_formatter(mpl.dates.DateFormatter('%d/%H UTC'))
177
        self.ax4.legend(loc='upper center', bbox_to_anchor=(0.5, 1.2), prop={'size': 12})
178
        plt.grid(b=True, which='major', axis='y', color='k', linestyle='--', linewidth=0.5)
179
        plt.setp(self.ax4.get_xticklabels(), visible=True)
180
        # OTHER OPTIONAL AXES TO PLOT
181
        # plot_irradiance
182
        # plot_precipitation
@@ 133-155 (lines=23) @@
130
        self.ax2.legend(lns, labs, loc='upper center',
131
                        bbox_to_anchor=(0.5, 1.2), ncol=2, prop={'size': 12})
132
133
    def plot_rh(self, rh, plot_range=None):
134
        """
135
        Required input:
136
            RH: Relative humidity (%)
137
        Optional Input:
138
            plot_range: Data range for making figure (list of (min,max,step))
139
        """
140
        # PLOT RELATIVE HUMIDITY
141
        if not plot_range: plot_range = [0, 100, 4]
142
        self.ax3 = fig.add_subplot(4, 1, 3, sharex=self.ax1)
143
        self.ax3.plot(self.dates,
144
                      rh,
145
                      'g-',
146
                      label='Relative Humidity')
147
        self.ax3.legend(loc='upper center', bbox_to_anchor=(0.5, 1.22), prop={'size': 12})
148
        plt.setp(self.ax3.get_xticklabels(), visible=True)
149
        plt.grid(b=True, which='major', axis='y', color='k', linestyle='--', linewidth=0.5)
150
        self.ax3.set_ylim(plot_range[0], plot_range[1], plot_range[2])
151
        plt.fill_between(self.dates, rh, plt.ylim()[0], color='g')
152
        plt.ylabel('Relative Humidity\n(%)', multialignment='center')
153
        plt.gca().xaxis.set_major_formatter(mpl.dates.DateFormatter('%d/%H UTC'))
154
        axtwin = self.ax3.twinx()
155
        axtwin.set_ylim(plot_range[0], plot_range[1], plot_range[2])
156
157
    def plot_pressure(self, p, plot_range=None):
158
        """