Reader small image

You're reading from  Mastering Matplotlib 2.x

Product typeBook
Published inNov 2018
Reading LevelBeginner
PublisherPackt
ISBN-139781789617696
Edition1st Edition
Languages
Right arrow
Author (1)
Benjamin Walter Keller
Benjamin Walter Keller
author image
Benjamin Walter Keller

Benjamin Walter Keller is currently a PhD candidate at McMaster University and gained his BSc in physics with a minor in computer science from the University of Calgary in 2011. His current research involves numerical modeling of galaxy evolution over cosmological timescales. As an undergraduate at the U of C, he worked on stacking radio polarization to examine faint extragalactic sources. He also worked in the POSSUM Working Group 2 to determine the requirements for stacking applications for the Australian SKA Pathfinder (ASKAP) radio telescope. He is particularly interested in questions involving stellar feedback (supernovae, stellar winds, and so on) and its impact on galaxies and their surrounding intergalactic medium.
Read more about Benjamin Walter Keller

Right arrow

Putting lines in place

This section describes adding horizontal and vertical lines along with adding and tweaking a background grid.

Adding horizontal and vertical lines

We will begin by importing our required libraries, as shown:

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
# Set up figure size and DPI for screen demo
plt.rcParams['figure.figsize'] = (6,4)
plt.rcParams['figure.dpi'] = 150
  1. We will create the simple sine plot that we saw in Chapter 1, Heavy Customization, as follows:
# Adding a horizontal and vertical line
nums = np.arange(0,10,0.1)
plt.plot(nums, np.sin(nums))

We will get the following output:

  1. Now, to add an annotation, say, a line that splits...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering Matplotlib 2.x
Published in: Nov 2018Publisher: PacktISBN-13: 9781789617696

Author (1)

author image
Benjamin Walter Keller

Benjamin Walter Keller is currently a PhD candidate at McMaster University and gained his BSc in physics with a minor in computer science from the University of Calgary in 2011. His current research involves numerical modeling of galaxy evolution over cosmological timescales. As an undergraduate at the U of C, he worked on stacking radio polarization to examine faint extragalactic sources. He also worked in the POSSUM Working Group 2 to determine the requirements for stacking applications for the Australian SKA Pathfinder (ASKAP) radio telescope. He is particularly interested in questions involving stellar feedback (supernovae, stellar winds, and so on) and its impact on galaxies and their surrounding intergalactic medium.
Read more about Benjamin Walter Keller