Created
June 4, 2019 01:42
-
-
Save jordij/0dcb6f60f61965b4f9eebaf6e6f98679 to your computer and use it in GitHub Desktop.
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
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import seaborn as sns | |
data_path = './transect_bathymetry.csv' | |
df = pd.read_csv(data_path) | |
df = df.apply(pd.to_numeric) | |
# sites distance in m | |
sites = [ | |
0.0, | |
3630.692532275101, | |
8490.190136457848, | |
25767.366984381923 | |
] | |
dfsites = df.loc[df['x'].isin(sites)] | |
sns.set(rc={'figure.figsize': (11, 4)}) | |
fig, ax = plt.subplots(nrows=1, ncols=1) | |
plt.yticks(np.arange(-20, 7, 4)) | |
ax.plot((df.x/1000), df.y) | |
plt.stem(dfsites.x/1000, dfsites.y, bottom=-20, linefmt='C0--', basefmt=' ') | |
plt.xlabel("Distance (km)") | |
plt.ylabel("Elevation (m +MSL)") | |
ax.axis([-0.5, 27, -20, 6]) # x and y limits | |
ax.set_xticks([s/1000 for s in sites], minor=True) | |
# Sites labels | |
y = 0 | |
for i, r in dfsites.iterrows(): | |
plt.annotate("S%i" % (y + 1), xy=(r["x"]/1000, | |
r["y"]), xytext=(r["x"]/1000 + 0.1, r["y"] + 0.5), size="15") | |
y += 1 | |
fig.tight_layout() | |
plt.savefig("./profile.png", bbox_inches='tight', dpi=200) | |
plt.show() | |
plt.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment