Code Duplication    Length = 22-23 lines in 2 locations

examples/meteogram_metpy.py 2 locations

@@ 139-161 (lines=23) @@
136
        self.ax3 = fig.add_subplot(4, 1, 3, sharex=self.ax1)
137
        self.ax3.plot(self.dates,
138
                      rh,
139
                      'g-',
140
                      label='Relative Humidity')
141
        self.ax3.legend(loc='upper center', bbox_to_anchor=(0.5, 1.22), prop={'size':12})
142
        plt.setp(self.ax3.get_xticklabels(), visible=True)
143
        plt.grid(b=True, which='major', axis='y', color='k', linestyle='--', linewidth=0.5)
144
        self.ax3.set_ylim(plot_range[0], plot_range[1], plot_range[2])
145
        plt.fill_between(self.dates, rh, plt.ylim()[0], color='g')
146
        plt.ylabel('Relative Humidity\n(%)', multialignment='center')
147
        plt.gca().xaxis.set_major_formatter(mpl.dates.DateFormatter('%d/%H UTC'))
148
        axtwin = self.ax3.twinx()
149
        axtwin.set_ylim(plot_range[0], plot_range[1], plot_range[2])
150
151
    def plot_pressure(self, p, plot_range=[970, 1030, 2]):
152
        """
153
        Required input:
154
            P: Mean Sea Level Pressure (hPa)
155
        Optional Input:
156
            plot_range: Data range for making figure
157
        """
158
        # PLOT PRESSURE
159
        self.ax4 = fig.add_subplot(4, 1, 4, sharex=self.ax1)
160
        self.ax4.plot(self.dates,
161
                      p,
162
                      'm',
163
                      label='Mean Sea Level Pressure')
164
        plt.ylabel('Mean Sea\nLevel Pressure\n(mb)', multialignment='center')
@@ 116-137 (lines=22) @@
113
                            label='Dewpoint')
114
        plt.fill_between(self.dates,
115
                         td,
116
                         plt.ylim()[0],
117
                         color='g')
118
        ax_twin = self.ax2.twinx()
119
        #    ax_twin.set_ylim(20,90,2)
120
        ax_twin.set_ylim(plot_range[0], plot_range[1], plot_range[2])
121
        lns = ln4 + ln5
122
        labs = [l.get_label() for l in lns]
123
        plt.gca().xaxis.set_major_formatter(mpl.dates.DateFormatter('%d/%H UTC'))
124
125
        self.ax2.legend(lns, labs, loc='upper center',
126
                        bbox_to_anchor=(0.5, 1.2), ncol=2, prop={'size':12})
127
128
    def plot_rh(self, rh, plot_range=[0, 100, 4]):
129
        """
130
        Required input:
131
            RH: Relative humidity (%)
132
        Optional Input:
133
            plot_range: Data range for making figure
134
        """
135
        # PLOT RELATIVE HUMIDITY
136
        self.ax3 = fig.add_subplot(4, 1, 3, sharex=self.ax1)
137
        self.ax3.plot(self.dates,
138
                      rh,
139
                      'g-',
140
                      label='Relative Humidity')