Skip to content

Commit 2af9147

Browse files
fix(altair): address review feedback for column-stratigraphic
Attempt 3/3 - fixes based on AI review
1 parent 3511400 commit 2af9147

1 file changed

Lines changed: 35 additions & 31 deletions

File tree

  • plots/column-stratigraphic/implementations

plots/column-stratigraphic/implementations/altair.py

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" pyplots.ai
1+
"""pyplots.ai
22
column-stratigraphic: Stratigraphic Column with Lithology Patterns
33
Library: altair 6.0.0 | Python 3.14.3
44
Quality: 85/100 | Created: 2026-03-15
@@ -9,10 +9,11 @@
99

1010

1111
# Data: Grand Canyon sedimentary section with 10 layers spanning Cambrian to Permian
12+
# Dramatic thickness variation (10-35 m) to showcase the format
1213
layers = pd.DataFrame(
1314
{
14-
"top": [0, 15, 35, 55, 70, 90, 110, 135, 155, 175],
15-
"bottom": [15, 35, 55, 70, 90, 110, 135, 155, 175, 200],
15+
"top": [0, 30, 45, 75, 85, 110, 120, 155, 170, 180],
16+
"bottom": [30, 45, 75, 85, 110, 120, 155, 170, 180, 200],
1617
"lithology": [
1718
"Sandstone",
1819
"Shale",
@@ -66,20 +67,20 @@
6667

6768
lithology_order = ["Sandstone", "Shale", "Limestone", "Siltstone", "Conglomerate"]
6869

69-
# Lithology pattern symbols for geological texture
70+
# Lithology pattern symbols — wider for better visibility
7071
pattern_symbols = {
71-
"Sandstone": "· · · · ·",
72-
"Shale": "— — —",
73-
"Limestone": "▤ ▤ ▤",
74-
"Siltstone": "╌ ╌ ╌",
75-
"Conglomerate": "◯ ◯ ◯",
72+
"Sandstone": · · · · · · ·",
73+
"Shale": "— — — —",
74+
"Limestone": "▤ ▤ ▤ ▤",
75+
"Siltstone": "╌ ╌ ╌ ╌",
76+
"Conglomerate": "◯ ◯ ◯ ◯",
7677
}
7778

7879
# Create multiple pattern rows per layer for denser texture fill
7980
pattern_rows = []
8081
for _, row in layers.iterrows():
8182
layer_height = row["bottom"] - row["top"]
82-
n_rows = max(2, int(layer_height / 7))
83+
n_rows = max(2, int(layer_height / 6))
8384
spacing = layer_height / (n_rows + 1)
8485
for i in range(n_rows):
8586
depth = row["top"] + spacing * (i + 1)
@@ -104,13 +105,13 @@
104105
age_df = pd.DataFrame(age_groups)
105106

106107
# Unconformity markers at major geological transitions
107-
unconformity_df = pd.DataFrame({"depth": [110, 155], "label": ["Unconformity", "Great Unconformity"]})
108+
unconformity_df = pd.DataFrame({"depth": [120, 170], "label": ["Unconformity", "Great Unconformity"]})
108109

109-
# Shared scales
110-
x_domain = [0, 16]
110+
# Shared scales — wider x domain for better canvas utilization
111+
x_domain = [0, 18]
111112
x_axis_none = alt.Axis(labels=False, ticks=False, domain=False, grid=False)
112113

113-
# Layer rectangles
114+
# Layer rectangles — wider column (x: 2.5 to 10.5)
114115
rects = (
115116
alt.Chart(layers)
116117
.mark_rect(stroke="#2C3E50", strokeWidth=1.5)
@@ -123,9 +124,10 @@
123124
labelFontSize=18,
124125
titleFontSize=22,
125126
tickCount=10,
126-
gridColor="#E0E0E0",
127+
gridColor="#D5D8DC",
127128
gridDash=[2, 4],
128129
domainColor="#2C3E50",
130+
domainWidth=1.5,
129131
),
130132
),
131133
y2="bottom:Q",
@@ -138,12 +140,13 @@
138140
legend=alt.Legend(
139141
titleFontSize=20,
140142
labelFontSize=18,
141-
symbolSize=500,
143+
symbolSize=600,
142144
orient="bottom",
143145
titlePadding=12,
144146
direction="horizontal",
145147
labelLimit=200,
146148
symbolStrokeWidth=1.5,
149+
symbolStrokeColor="#2C3E50",
147150
padding=20,
148151
columns=5,
149152
),
@@ -157,47 +160,47 @@
157160
alt.Tooltip("thickness:Q", title="Thickness (m)"),
158161
],
159162
)
160-
.transform_calculate(x="3", x2="9")
163+
.transform_calculate(x="2.5", x2="10.5")
161164
)
162165

163-
# Dense pattern texture overlay
166+
# Dense pattern texture overlay — bolder and more prominent
164167
pattern_text = (
165168
alt.Chart(pattern_df)
166-
.mark_text(fontSize=16, color="#2C3E50", opacity=0.6)
169+
.mark_text(fontSize=17, color="#2C3E50", opacity=0.65, fontWeight="bold")
167170
.encode(y=alt.Y("depth:Q"), x=alt.X("x_mid:Q", scale=alt.Scale(domain=x_domain)), text="pattern:N")
168-
.transform_calculate(x_mid="6")
171+
.transform_calculate(x_mid="6.5")
169172
)
170173

171174
# Formation name labels to the right
172175
formation_labels = (
173176
alt.Chart(layers)
174177
.mark_text(fontSize=17, fontWeight="bold", align="left", color="#1B2631")
175178
.encode(y=alt.Y("mid_depth:Q"), x=alt.X("x_pos:Q", scale=alt.Scale(domain=x_domain)), text="formation:N")
176-
.transform_calculate(x_pos="9.4")
179+
.transform_calculate(x_pos="11.0")
177180
)
178181

179-
# Thickness annotations (subtle, on the right)
182+
# Thickness annotations — larger font for readability
180183
thickness_labels = (
181184
alt.Chart(layers)
182-
.mark_text(fontSize=13, align="right", color="#7F8C8D", fontStyle="italic")
185+
.mark_text(fontSize=16, align="right", color="#7F8C8D", fontStyle="italic")
183186
.encode(y=alt.Y("mid_depth:Q"), x=alt.X("x_pos:Q", scale=alt.Scale(domain=x_domain)), text="label:N")
184-
.transform_calculate(x_pos="15.8", label="datum.thickness + ' m'")
187+
.transform_calculate(x_pos="17.8", label="datum.thickness + ' m'")
185188
)
186189

187190
# Age period labels to the left
188191
age_labels = (
189192
alt.Chart(age_df)
190193
.mark_text(fontSize=18, fontStyle="italic", fontWeight="bold", align="right", color="#2C3E50")
191194
.encode(y=alt.Y("mid_depth:Q"), x=alt.X("x_pos:Q", scale=alt.Scale(domain=x_domain)), text="age:N")
192-
.transform_calculate(x_pos="2.0")
195+
.transform_calculate(x_pos="1.8")
193196
)
194197

195198
# Age bracket vertical lines
196199
age_brackets_v = (
197200
alt.Chart(age_df)
198201
.mark_rule(strokeWidth=2.5, color="#2C3E50")
199202
.encode(y=alt.Y("top:Q"), y2="bottom:Q", x=alt.X("x_pos:Q", scale=alt.Scale(domain=x_domain)))
200-
.transform_calculate(x_pos="2.5")
203+
.transform_calculate(x_pos="2.2")
201204
)
202205

203206
# Age bracket horizontal ticks (top and bottom of each age group)
@@ -211,22 +214,23 @@
211214
alt.Chart(bracket_ticks_df)
212215
.mark_rule(strokeWidth=2.5, color="#2C3E50")
213216
.encode(y=alt.Y("depth:Q"), x=alt.X("x1:Q", scale=alt.Scale(domain=x_domain)), x2="x2:Q")
214-
.transform_calculate(x1="2.5", x2="2.8")
217+
.transform_calculate(x1="2.2", x2="2.5")
215218
)
216219

217220
# Unconformity markers — red dashed lines at key geological transitions
218221
unconformity_rules = (
219222
alt.Chart(unconformity_df)
220223
.mark_rule(strokeWidth=4, color="#C0392B", strokeDash=[8, 4])
221224
.encode(y=alt.Y("depth:Q"), x=alt.X("x1:Q", scale=alt.Scale(domain=x_domain)), x2="x2:Q")
222-
.transform_calculate(x1="3", x2="9")
225+
.transform_calculate(x1="2.5", x2="10.5")
223226
)
224227

228+
# Unconformity labels — positioned to the right of column to avoid overlapping patterns
225229
unconformity_labels_chart = (
226230
alt.Chart(unconformity_df)
227-
.mark_text(fontSize=12, color="#C0392B", fontWeight="bold", align="center", dy=14)
231+
.mark_text(fontSize=13, color="#C0392B", fontWeight="bold", align="left", dy=-10)
228232
.encode(y=alt.Y("depth:Q"), x=alt.X("x_mid:Q", scale=alt.Scale(domain=x_domain)), text="label:N")
229-
.transform_calculate(x_mid="6")
233+
.transform_calculate(x_mid="11.0")
230234
)
231235

232236
# Combine all layers
@@ -243,7 +247,7 @@
243247
+ unconformity_labels_chart
244248
)
245249
.properties(
246-
width=1200,
250+
width=1400,
247251
height=900,
248252
title=alt.Title(
249253
"column-stratigraphic · altair · pyplots.ai",

0 commit comments

Comments
 (0)