Code Duplication    Length = 50-52 lines in 2 locations

metpy/plots/skewt.py 2 locations

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