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/b09482d66b543a63a805b087d0b8e98ab8bb00026746f24df942f4414960f7c6.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/d427b21cda1a1b0a7326ceafa56ffa04e866fac738e8b70c14d8309111734307.png