Code Duplication    Length = 23-23 lines in 2 locations

examples/meteogram_metpy.py 2 locations

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