Code Duplication    Length = 50-52 lines in 2 locations

metpy/plots/skewt.py 2 locations

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