Code Duplication    Length = 50-52 lines in 2 locations

metpy/plots/skewt.py 2 locations

@@ 350-401 (lines=52) @@
347
            Space, in normalized axes coordinates, to leave above/below plot
348
            before clipping wind barbs in the y-direction. Defaults to 0.08.
349
        kwargs
350
            Other keyword arguments to pass to :func:`~matplotlib.pyplot.barbs`
351
352
        Returns
353
        -------
354
        matplotlib.quiver.Barbs
355
            instance created
356
357
        See Also
358
        --------
359
        :func:`matplotlib.pyplot.barbs`
360
        """
361
        # Assemble array of x-locations in axes space
362
        x = np.empty_like(p)
363
        x.fill(xloc)
364
365
        # Do barbs plot at this location
366
        b = self.ax.barbs(x, p, u, v,
367
                          transform=self.ax.get_yaxis_transform(which='tick2'),
368
                          clip_on=True, **kwargs)
369
370
        # Override the default clip box, which is the axes rectangle, so we can have
371
        # barbs that extend outside.
372
        ax_bbox = transforms.Bbox([[xloc - x_clip_radius, -y_clip_radius],
373
                                   [xloc + x_clip_radius, 1.0 + y_clip_radius]])
374
        b.set_clip_box(transforms.TransformedBbox(ax_bbox, self.ax.transAxes))
375
        return b
376
377
    def plot_dry_adiabats(self, t0=None, p=None, **kwargs):
378
        r"""Plot dry adiabats.
379
380
        Adds dry adiabats (lines of constant potential temperature) to the
381
        plot. The default style of these lines is dashed red lines with an alpha
382
        value of 0.5. These can be overridden using keyword arguments.
383
384
        Parameters
385
        ----------
386
        t0 : array_like, optional
387
            Starting temperature values in Kelvin. If none are given, they will be
388
            generated using the current temperature range at the bottom of
389
            the plot.
390
        p : array_like, optional
391
            Pressure values to be included in the dry adiabats. If not
392
            specified, they will be linearly distributed across the current
393
            plotted pressure range.
394
        kwargs
395
            Other keyword arguments to pass to :class:`matplotlib.collections.LineCollection`
396
397
        Returns
398
        -------
399
        matplotlib.collections.LineCollection
400
            instance created
401
402
        See Also
403
        --------
404
        :func:`~metpy.calc.thermo.dry_lapse`
@@ 299-348 (lines=50) @@
296
        kwargs
297
            Other keyword arguments to pass to :func:`~matplotlib.pyplot.semilogy`
298
299
        Returns
300
        -------
301
        list[matplotlib.lines.Line2D]
302
            lines plotted
303
304
        See Also
305
        --------
306
        :func:`matplotlib.pyplot.semilogy`
307
        """
308
        # Skew-T logP plotting
309
        t, p = delete_masked_points(t, p)
310
        l = self.ax.semilogy(t, p, *args, **kwargs)
311
312
        # Disables the log-formatting that comes with semilogy
313
        self.ax.yaxis.set_major_formatter(ScalarFormatter())
314
        self.ax.yaxis.set_major_locator(MultipleLocator(100))
315
        self.ax.yaxis.set_minor_formatter(NullFormatter())
316
        if not self.ax.yaxis_inverted():
317
            self.ax.invert_yaxis()
318
319
        # Try to make sane default temperature plotting
320
        self.ax.xaxis.set_major_locator(MultipleLocator(10))
321
        self.ax.set_xlim(-50, 50)
322
323
        return l
324
325
    def plot_barbs(self, p, u, v, xloc=1.0, x_clip_radius=0.08, y_clip_radius=0.08, **kwargs):
326
        r"""Plot wind barbs.
327
328
        Adds wind barbs to the skew-T plot. This is a wrapper around the
329
        `barbs` command that adds to appropriate transform to place the
330
        barbs in a vertical line, located as a function of pressure.
331
332
        Parameters
333
        ----------
334
        p : array_like
335
            pressure values
336
        u : array_like
337
            U (East-West) component of wind
338
        v : array_like
339
            V (North-South) component of wind
340
        xloc : float, optional
341
            Position for the barbs, in normalized axes coordinates, where 0.0
342
            denotes far left and 1.0 denotes far right. Defaults to far right.
343
        x_clip_radius : float, optional
344
            Space, in normalized axes coordinates, to leave before clipping
345
            wind barbs in the x-direction. Defaults to 0.08.
346
        y_clip_radius : float, optional
347
            Space, in normalized axes coordinates, to leave above/below plot
348
            before clipping wind barbs in the y-direction. Defaults to 0.08.
349
        kwargs
350
            Other keyword arguments to pass to :func:`~matplotlib.pyplot.barbs`
351