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/d2641f2b0bd6eed532a9e0577774220a91d05f29880188f717d268213493dd9e.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/c2b2c09b083273d902c1f4e713dffff589d8571b7fc255c6307baaf93b4ba4ac.png