Remove pylab examples
parent
b217fd47fb
commit
1509655ed9
@ -1,17 +1,16 @@
|
|||||||
"""
|
"""
|
||||||
Simple pylab example
|
Simple matplotlib example
|
||||||
|
|
||||||
Use pylab when you are in an interactive shell. This example really should be copied into a RPEL.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pylab import plot, show
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
x_numbers = [1, 2, 3]
|
x_numbers = np.array([1, 2, 3])
|
||||||
y_numbers = [2, 4, 6]
|
y_numbers = np.array([2, 4, 6])
|
||||||
|
|
||||||
my_graph = plot(x_numbers, y_numbers, marker='o')
|
|
||||||
# my_graph = plot(x_numbers, y_numbers, 'o')
|
|
||||||
|
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
ax.plot(x_numbers, y_numbers, marker="o")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
show()
|
plt.show()
|
||||||
|
|||||||
@ -1,20 +1,32 @@
|
|||||||
from pylab import legend, plot, show, title, xlabel, ylabel, axis
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
nyc_temp_2000 = [31.3, 37.3, 47.2, 51.0, 63.5, 71.3, 72.3, 72.7, 66.0, 57.0, 45.3, 31.1]
|
|
||||||
nyc_temp_2006 = [40.9, 35.7, 43.1, 55.7, 63.1, 71.0, 77.9, 75.8, 66.6, 56.2, 51.9, 43.6]
|
nyc_temp_2000 = np.array([
|
||||||
nyc_temp_2012 = [37.3, 40.9, 50.9, 54.8, 65.1, 71.0, 78.8, 76.7, 68.8, 58.0, 43.9, 41.5]
|
31.3, 37.3, 47.2, 51.0, 63.5, 71.3,
|
||||||
|
72.3, 72.7, 66.0, 57.0, 45.3, 31.1
|
||||||
months = range(1, 13)
|
])
|
||||||
|
nyc_temp_2006 = np.array([
|
||||||
plot(months, nyc_temp_2000, months, nyc_temp_2006, months, nyc_temp_2012)
|
40.9, 35.7, 43.1, 55.7, 63.1, 71.0,
|
||||||
|
77.9, 75.8, 66.6, 56.2, 51.9, 43.6
|
||||||
title('Average monthly temperature in NYC')
|
])
|
||||||
|
nyc_temp_2012 = np.array([
|
||||||
xlabel("Month")
|
37.3, 40.9, 50.9, 54.8, 65.1, 71.0,
|
||||||
ylabel("Temperature")
|
78.8, 76.7, 68.8, 58.0, 43.9, 41.5
|
||||||
|
])
|
||||||
legend([2000, 2006, 2012])
|
|
||||||
|
months = np.arange(1, 13)
|
||||||
axis(ymin=0)
|
|
||||||
|
fig, ax = plt.subplots()
|
||||||
show()
|
|
||||||
|
ax.plot(months, nyc_temp_2000, marker="o", label="2000")
|
||||||
|
ax.plot(months, nyc_temp_2006, marker="o", label="2006")
|
||||||
|
ax.plot(months, nyc_temp_2012, marker="o", label="2012")
|
||||||
|
|
||||||
|
ax.set_title("Average monthly temperature in NYC")
|
||||||
|
ax.set_xlabel("Month")
|
||||||
|
ax.set_ylabel("Temperature")
|
||||||
|
|
||||||
|
ax.set_ylim(bottom=0) # equivalent to axis(ymin=0)
|
||||||
|
ax.legend()
|
||||||
|
|
||||||
|
plt.show()
|
||||||
|
|||||||
@ -1,13 +1,28 @@
|
|||||||
from pylab import legend, plot, show
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
nyc_temp_2000 = [31.3, 37.3, 47.2, 51.0, 63.5, 71.3, 72.3, 72.7, 66.0, 57.0, 45.3, 31.1]
|
nyc_temp_2000 = [
|
||||||
nyc_temp_2006 = [40.9, 35.7, 43.1, 55.7, 63.1, 71.0, 77.9, 75.8, 66.6, 56.2, 51.9, 43.6]
|
31.3, 37.3, 47.2, 51.0, 63.5, 71.3,
|
||||||
nyc_temp_2012 = [37.3, 40.9, 50.9, 54.8, 65.1, 71.0, 78.8, 76.7, 68.8, 58.0, 43.9, 41.5]
|
72.3, 72.7, 66.0, 57.0, 45.3, 31.1
|
||||||
|
]
|
||||||
|
nyc_temp_2006 = [
|
||||||
|
40.9, 35.7, 43.1, 55.7, 63.1, 71.0,
|
||||||
|
77.9, 75.8, 66.6, 56.2, 51.9, 43.6
|
||||||
|
]
|
||||||
|
nyc_temp_2012 = [
|
||||||
|
37.3, 40.9, 50.9, 54.8, 65.1, 71.0,
|
||||||
|
78.8, 76.7, 68.8, 58.0, 43.9, 41.5
|
||||||
|
]
|
||||||
|
|
||||||
months = range(1, 13)
|
months = range(1, 13)
|
||||||
|
|
||||||
plot(months, nyc_temp_2000, months, nyc_temp_2006, months, nyc_temp_2012)
|
plt.plot(months, nyc_temp_2000)
|
||||||
|
plt.plot(months, nyc_temp_2006)
|
||||||
|
plt.plot(months, nyc_temp_2012)
|
||||||
|
|
||||||
legend([2000, 2006, 2012])
|
plt.legend([2000, 2006, 2012])
|
||||||
|
plt.xlabel("Month")
|
||||||
|
plt.ylabel("Temperature")
|
||||||
|
plt.title("NYC Monthly Temperatures")
|
||||||
|
|
||||||
show()
|
plt.show()
|
||||||
|
|||||||
@ -1,12 +1,20 @@
|
|||||||
from pylab import plot, show
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
nyc_temp = [50.9, 60.3, 54.4, 52.4, 51.5, 52.8, 56.8, 55.0, 55.3, 54.0, 56.7, 56.4, 57.3]
|
nyc_temp = [
|
||||||
|
50.9, 60.3, 54.4, 52.4, 51.5, 52.8,
|
||||||
|
56.8, 55.0, 55.3, 54.0, 56.7, 56.4, 57.3
|
||||||
|
]
|
||||||
|
|
||||||
dec_nyc_temp = list(map(lambda x: Decimal(str(x)), nyc_temp))
|
# Preserve Decimal behavior
|
||||||
|
dec_nyc_temp = [Decimal(str(x)) for x in nyc_temp]
|
||||||
|
|
||||||
years = range(2000, 2013)
|
years = list(range(2000, 2013))
|
||||||
|
|
||||||
plot(years, dec_nyc_temp, marker='o')
|
plt.plot(years, dec_nyc_temp, marker="o")
|
||||||
|
plt.xlabel("Year")
|
||||||
|
plt.ylabel("Temperature")
|
||||||
|
plt.title("NYC Temperature by Year")
|
||||||
|
|
||||||
show()
|
plt.show()
|
||||||
|
|||||||
@ -1,7 +1,14 @@
|
|||||||
from pylab import plot, show
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
nyc_temp = [53.9, 56.3, 56.4, 53.4, 54.5, 55.8, 56.8, 55.0, 55.3, 54.0, 56.7, 56.4, 57.3]
|
nyc_temp = np.array([
|
||||||
|
53.9, 56.3, 56.4, 53.4, 54.5, 55.8,
|
||||||
|
56.8, 55.0, 55.3, 54.0, 56.7, 56.4, 57.3
|
||||||
|
])
|
||||||
|
|
||||||
plot(nyc_temp, marker="o")
|
plt.plot(nyc_temp, marker="o")
|
||||||
|
plt.xlabel("Day")
|
||||||
|
plt.ylabel("Temperature (°F)")
|
||||||
|
plt.title("NYC Temperatures")
|
||||||
|
|
||||||
show()
|
plt.show()
|
||||||
|
|||||||
Loading…
Reference in New Issue