set_titles_and_labels

set_titles_and_labels#

This notebook is a simple example of the GeoCAT-viz function set_titles_and_labels.

# Import packages:

import numpy as np
import matplotlib.pyplot as plt

import geocat.viz as gv
# Generate example data:

npts = 500

x = 500 + 0.9 * np.arange(0, npts) * np.cos(np.pi / 100 * np.arange(0, npts))
y = 500 + 0.9 * np.arange(0, npts) * np.sin(np.pi / 100 * np.arange(0, npts))
# Create plot with a subtitle

# Create a figure
fig, ax = plt.subplots()

# Plot the example data
ax.plot(x, y)

# Use geocat.viz.util convenience function to set titles and labels
gv.set_titles_and_labels(ax,
                         maintitle="Title",
                         maintitlefontsize=24,
                         subtitle="Subtitle",
                         xlabel="x",
                         ylabel="y",
                         labelfontsize=16)

# Show the plot
plt.show();
../_images/b9c2026dbe5946f92b8fd13877e3bba0ba1a1b7f706f2606793585cfae52fb88.png
# Create plot with left and right subtitles

# Create a figure
fig, ax = plt.subplots()

# Plot the example data
ax.plot(x, y)

# Use geocat.viz.util convenience function to set titles and labels
gv.set_titles_and_labels(ax,
                         maintitle="Title",
                         maintitlefontsize=24,
                         lefttitle="Left title",
                         righttitle='Right title',
                         xlabel="x",
                         ylabel="y",
                         labelfontsize=16)

# Show the plot
plt.show();
../_images/f531a5c2dc731b0020293fa703c0ec65e7924f83fbd55d61f04b3a34a320aa8d.png