Code Duplication    Length = 50-52 lines in 2 locations

metpy/plots/skewt.py 2 locations

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