Created
February 4, 2019 07:49
-
-
Save jamesboyd2008/9ffb3288b23021241be987f35763f4c6 to your computer and use it in GitHub Desktop.
This is a way to generate a scatter plot with Python and Matplotlib.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This program generates a scatter plot. | |
import numpy as np | |
import matplotlib.pyplot as plt | |
colors = ['b', 'c', 'y', 'm', 'r', 'g'] | |
# twoV | |
x = np.array([8, 6, 9, 8.5, 7.5, 6]) | |
y = np.array([9, 10, 11, 8.5, 11.5, 11]) | |
plt.scatter(x, y, c = colors[0], label = "2V") | |
# threeV | |
x = np.array([3, 5, 4, 0, 10, 2]) | |
y = np.array([0, 10, 20, 0, 9, 3]) | |
plt.scatter(x, y, c = colors[1], label = "3V") | |
# fourV | |
x = np.array([13, 12, 11, 12, 12, 10]) | |
y = np.array([11, 8, 4, 4, 10, 1]) | |
plt.scatter(x, y, c = colors[2], label = "4V") | |
# fiveV | |
x = np.array([14.5, 14.5, 14.5, 14.5, 15, 14]) | |
y = np.array([15, 16, 19, 1, 20, 10]) | |
plt.scatter(x, y, c = colors[3], label = "5V") | |
# sixV | |
x = np.array([17, 18, 19, 19, 16, 18]) | |
y = np.array([7, 17, 0, 20, 10, 15]) | |
plt.scatter(x, y, c = colors[4], label = "6V") | |
# sevenV | |
x = np.array([22, 23, 27, 18.5, 22, 20]) | |
y = np.array([14, 7, 10, 8.5, 13.5, 7]) | |
plt.scatter(x, y, c = colors[5], label = "7V") | |
# generate the scatter plot | |
plt.legend() | |
plt.grid(True) | |
plt.title("Locations of Voltages Measured with Dipole Arrangement") | |
# plt.show() | |
plt.savefig('plot1') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment