Update README.md
Browse files
README.md
CHANGED
|
@@ -40,3 +40,48 @@ To work with Hugging Face datasets in Python:
|
|
| 40 |
pip install datasets
|
| 41 |
pip install pillow soundfile numpy
|
| 42 |
pip install pillow soundfile huggingface_hub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
pip install datasets
|
| 41 |
pip install pillow soundfile numpy
|
| 42 |
pip install pillow soundfile huggingface_hub
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## Visual Example
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
import pygmt
|
| 49 |
+
import pandas as pd
|
| 50 |
+
|
| 51 |
+
# Sample DataFrame
|
| 52 |
+
data = {
|
| 53 |
+
"longitude": [-90.47, -90.45, -90.44, -90.42, -90.40, -90.38, -90.36],
|
| 54 |
+
"latitude": [28.27, 28.29, 28.31, 28.33, 28.35, 28.37, 28.39],
|
| 55 |
+
"temp": [-18.5, -18.5, -18.5, -18.5, -18.5, -18.5, -18.2] # One different value
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
df = pd.DataFrame(data)
|
| 59 |
+
|
| 60 |
+
fig = pygmt.Figure()
|
| 61 |
+
|
| 62 |
+
# Set region based on data
|
| 63 |
+
minlon, maxlon = df["longitude"].min() - 1, df["longitude"].max() + 1
|
| 64 |
+
minlat, maxlat = df["latitude"].min() - 1, df["latitude"].max() + 1
|
| 65 |
+
|
| 66 |
+
# Create basemap
|
| 67 |
+
fig.basemap(region=[minlon, maxlon, minlat, maxlat], projection="M15c", frame=True)
|
| 68 |
+
fig.coast(shorelines="1/0.5p", land="lightgray", water="white")
|
| 69 |
+
|
| 70 |
+
# Define CPT based on temperature range
|
| 71 |
+
pygmt.makecpt(cmap="hot", series=[df["temp"].min(), df["temp"].max()])
|
| 72 |
+
|
| 73 |
+
# Plot colored points
|
| 74 |
+
fig.plot(
|
| 75 |
+
x=df["longitude"],
|
| 76 |
+
y=df["latitude"],
|
| 77 |
+
style="c0.5c",
|
| 78 |
+
cmap=True,
|
| 79 |
+
fill=df["temp"],
|
| 80 |
+
pen="black"
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
# Add colorbar
|
| 84 |
+
fig.colorbar(frame='af+l"Temperature (°C)"')
|
| 85 |
+
|
| 86 |
+
fig.show()
|
| 87 |
+
```
|