Exemple #1
0
            180.)**10 + pyg.cos(10 +
                                (2 * np.pi / 180.)**2 * lat * lon) * pyg.cos(
                                    2 * np.pi * lat / 180.)

ax = pyg.plot.AxesWrapper()

contour_dict = pyg.clfdict(min=-1.2,
                           axes=ax,
                           cdelt=0.4,
                           ndiv=3,
                           nf=2,
                           nl=1,
                           extend='both',
                           cmap='RdGy')

pyg.vcontour(z, **contour_dict)
ax.setp(title='Using helper function to set up contour levels')
ax.clabel(ax.plots[1], colors='k', fmt='%.1f', fontsize=10, inline=False)

pyl.ion()
ax.render()
############################################################################
# ``contour_dict`` contains a dictionary of the various plotting parameters
#

print(contour_dict)

############################################################################
# ``ax.plots`` contains a list of the various pygeode plot objects
#
Exemple #2
0
import pylab as pyl
import pygeode as pyg, numpy as np

lat = pyg.regularlat(60)
lon = pyg.regularlon(120)

x = pyg.sin(2 * np.pi * lon / 180.) * pyg.exp(-(lat - 30)**2 / (2 * 10**2))
y = pyg.sin(2 * np.pi * lon / 180.) * pyg.exp(-(lat + 40)**2 / (2 * 10**2))

pyl.ioff()
ax = pyg.plot.AxesWrapper()
pyg.vcontour(y,
             clevs=np.linspace(-1, 1, 21),
             clines=None,
             cmap=pyl.cm.PuBuGn,
             axes=ax)
pyg.vcontour(x,
             clevs=None,
             clines=np.linspace(-1, 1, 21),
             linewidths=1.,
             colors='k',
             axes=ax)

ax.setp(title='Filled contours and contour lines')

pyl.ion()
ax.render(1)
Exemple #3
0
"""

import pylab as pyl
pyl.ioff()

import pygeode as pyg
import numpy as np
from pygeode.tutorial import t2

# Generate some data for a scatter plot
N = 50
x_values = np.linspace(-1, 1, N)
colors = np.random.rand(N)
area = 1000 * np.random.rand(N) * (1 - abs(x_values))

x = pyg.NamedAxis(values=x_values, name='x')
y = pyg.NamedAxis(values=x_values + np.random.rand(N), name='y')

ax_scatter = pyg.vscatter(x, y, c=colors, s=area, alpha=0.5)

# Make a vcontour
ax_vcontour = pyg.vcontour(t2.Temp(pres=500, time='10 May 2012') *
                           (pyg.cos(t2.lat)) * pyg.sin(t2.lon),
                           cmap='Oranges')

# Stitch the axes together side by side into a grid
ax_both = pyg.plot.grid([[ax_scatter, ax_vcontour]])

pyl.ion()
ax_both.render()
"""
Contour plot with hatches
=========================
"""
import pylab as pyl
pyl.ion()

import pygeode as pyg
import numpy as np
from pygeode.tutorial import t1

ax = pyg.plot.AxesWrapper()

# Pass **kwargs to matplotlib contourf
pyg.vcontour(t1.Temp, clines=5, clevels=5, colors='k', axes=ax)
pyg.vcontour(t1.Temp, clevels=5, cmap='BuGn', axes=ax)
ax.clabel(ax.plots[0], colors='k', fmt='%d', fontsize=14)
pyg.vcontour(t1.Temp,
             levels=[200, 280],
             linewidth=0,
             hatches=['..'],
             alpha=0,
             axes=ax)

ax.setp(title='Plot specific contours and hatching')

ax.render(1)
"""
import pygeode as pyg, numpy as np, pylab as pyl
from cartopy import crs as ccrs
import cartopy
from cartopy.feature.nightshade import Nightshade
from datetime import datetime as dt

lat = pyg.gausslat(60)
lon = pyg.regularlon(120)

x = pyg.sin(2*np.pi * lon / 180.) * pyg.exp(-(lat - 30)**2 / (2*10**2))
y = pyg.sin(2*np.pi * lon / 180.) * pyg.exp(-(lat + 40)**2 / (2*10**2))

pyl.ioff()
prj = dict(central_longitude = 60)
#ax = pyg.plot.CartopyAxes(projection = 'NearsidePerspective', prj_args = prj)

map = dict(projection = 'NearsidePerspective', prj_args = prj)
#map = dict(projection = 'LambertConformal', prj_args = prj)

cl = pyg.cldict(0.1, nozero=True)
ax = pyg.vcontour(x, map = map, **cl)
ax.add_feature(cartopy.feature.OCEAN)
ax.add_feature(Nightshade(dt.utcnow()))
ax.setp(title = '')

pyl.ion()
ax.render(2)

ax.ax.tissot(facecolor='orange', alpha=0.8)