Example #1
0
# coding: utf-8

# Bar plot demo
# =========
# This example shows you how to make a bar plot using the `psyplot.project.ProjectPlotter.barplot` method.

# In[ ]:

import psyplot.project as psy
# get_ipython().magic(u'matplotlib inline')
# get_ipython().magic(u'config InlineBackend.close_figures = False')


# In[ ]:

axes = iter(psy.multiple_subplots(2, 2, n=3))
for var in ['t2m', 'u', 'v']:
    psy.plot.barplot(
        'demo.nc',  # netCDF file storing the data
        name=var, # one plot for each variable
        y=[0, 1],  # two bars in total
        z=0, x=0,      # choose latitude and longitude as dimensions
        ylabel="{desc}",  # use the longname and units on the y-axis
        ax=next(axes),
        color='coolwarm', legend=False, xticklabels='%B %Y'
    )
bars = psy.gcp(True)
bars.show()


# In[ ]:
Example #2
0
maps.update(color='absolute', cmap='viridis', vcmap='RdBu_r', vcbar='r', 
            clabel='{desc}', vclabel='Wind Speed [%(units)s]')


# Summary
# -------
# To sum it all up:
# 
# * The *mapplot* method visualizes scalar fields
# * The *mapvector* method visualizes vector fiels
# * The *mapcombined* method visualizes scalar and vector fields

# In[ ]:

# create the subplots
axes = psy.multiple_subplots(2, 2, n=4, for_maps=True)
# disable the automatic showing of the figures
psy.rcParams['auto_show'] = False
# create plots for the scalar fields
maps = psy.plot.mapplot('demo.nc', name='t2m', clabel='{desc}', ax=axes[0], 
                        title='scalar field')
# create plots for scalar and vector fields
combined = psy.plot.mapcombined(
    'demo.nc', name=[['t2m', ['u', 'v']]], clabel='{desc}', arrowsize=100, 
    cmap='RdBu_r', ax=axes[1], title='scalar and vector field')
# create two plots for vector field
mapvectors = psy.plot.mapvector('demo.nc', name=[['u', 'v'], ['u', 'v']], 
                                ax=axes[2:])
# where one of them shall be a stream plot
mapvectors[0].update(arrowsize=100, title='quiver plot')
mapvectors[1].update(plot='stream', title='stream plot')