Created
October 21, 2019 12:40
-
-
Save xjtu-blacksmith/9a21f482de6c536395419e38273d188a to your computer and use it in GitHub Desktop.
The codes to produced a comprehensive graph for temperature field (class homework)
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
3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | 2.9 | 2.8 | 2.71 | 2.62 | 2.54 | 2.49 | 2.45 | 2.43 | 2.41 | 2.41 | 2.4 | 2.4 | 2.4 | 2.4 | 2.4 | |
3 | 2.8 | 2.61 | 2.42 | 2.23 | 2.07 | 1.96 | 1.89 | 1.85 | 1.82 | 1.81 | 1.81 | 1.8 | 1.8 | 1.8 | 1.8 | |
3 | 2.71 | 2.42 | 2.11 | 1.81 | 1.54 | 1.38 | 1.3 | 1.25 | 1.23 | 1.21 | 1.2 | 1.2 | 1.2 | 1.2 | 1.2 | |
3 | 2.62 | 2.23 | 1.81 | 1.36 | 0.91 | 0.74 | 0.66 | 0.63 | 0.61 | 0.6 | 0.6 | 0.6 | 0.6 | 0.6 | 0.6 | |
3 | 2.54 | 2.07 | 1.54 | 0.91 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
3 | 2.49 | 1.96 | 1.38 | 0.74 | 0 | |||||||||||
3 | 2.45 | 1.89 | 1.3 | 0.66 | 0 | |||||||||||
3 | 2.43 | 1.85 | 1.25 | 0.63 | 0 | |||||||||||
3 | 2.42 | 1.83 | 1.23 | 0.62 | 0 | |||||||||||
3 | 2.41 | 1.82 | 1.21 | 0.61 | 0 | |||||||||||
3 | 2.41 | 1.81 | 1.21 | 0.6 | 0 |
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
# Dealing with data | |
import csv | |
import matplotlib.pyplot as plt | |
import scipy.ndimage | |
import numpy as np | |
#import scipy.ndimage | |
with open('data.csv') as f: | |
f_csv = csv.reader(f) | |
data = np.array(list(f_csv)) | |
data[data == ''] = '0' | |
data = np.array(data, dtype=float) * 10 | |
#data = scipy.ndimage.zoom(data, 3) | |
plt.matshow(data, interpolation='gaussian', origin='upper', extent=None, cmap='hot') | |
plt.colorbar() | |
ax = plt.gca() | |
ax.set_xlim([0, 15]) | |
ax.set_ylim([11, 0]) | |
ax.xaxis.set_minor_locator(plt.MultipleLocator(1)) | |
ax.yaxis.set_minor_locator(plt.MultipleLocator(1)) | |
ax.grid(which='minor', color='black', linestyle='-', linewidth=1) | |
# plt.contourf(range(0, 16), range(12, 0, -1), data) | |
for i in range(12): | |
for j in range(16): | |
if j < 6 or i < 6: | |
plt.text(j, i, "{:.1f}".format(data[i, j]), ha="center", va="center", color="#3333dd", fontsize=16) | |
cs = plt.contour(data, antialiased=True, levels=[12, 18, 24], colors=['#66ee66', '#66ee66', '#33dd33']) | |
plt.clabel(cs, fmt='%.0fв„ѓ', colors=['#66ee66', '#66ee66', '#33dd33'], fontsize=18) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment