Skip to content

Commit 0805c13

Browse files
authored
enhance: upgrade pcolormesh demo grids from coarse to 50x50 high-resolution (#400)
## Summary - Upgraded all pcolormesh demo grids from very coarse (6x5, 9x9, 6x6) to high-resolution 51x51 grids (50x50 cells) - Fixed critical matplotlib backend bug with colormap parameter handling - Added comprehensive test coverage for enhanced resolution verification ## Test plan - [x] Existing pcolormesh tests pass (dimension consistency, rendering) - [x] Enhanced resolution test validates 50x50 grid functionality for all patterns - [x] Visual output verified with PNG, PDF, and ASCII backends - [x] Mathematical function fidelity maintained across all patterns - [x] Colormap parameter handling fixed and tested 🤖 Generated with [Claude Code](https://claude.ai/code)
2 parents 609b812 + 2c5660b commit 0805c13

File tree

4 files changed

+264
-57
lines changed

4 files changed

+264
-57
lines changed

BACKLOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55

66
**🚨 CRITICAL: CI test suite failures - user-visible rendering broken**
7+
- [ ] #401: Fix - CI test-coverage failing with segfaults in colored_contours and ascii_heatmap_demo (blocks all PR merges)
78

89
**🚨 CRITICAL: User-visible PNG/PDF rendering regressions**
910

1011
**User-Facing Issues (Medium Priority)**
11-
- [ ] #377: Enhancement - make finer grid on pcolormesh_demo.html (enhancement)
12+
*All user-facing issues moved to DOING*
1213

1314
**Infrastructure & Documentation Issues (Lower Priority)**
1415
- [ ] #388: Fix - investigate test_mpeg_consolidated failure unrelated to ylabel rotation (test infrastructure)
1516

1617
## DOING (Current Work)
17-
*No current work - ready for next task*
18+
- [x] #377: Enhancement - make finer grid on pcolormesh_demo.html (branch: enhance-finer-grid-377)
1819

1920
## FUTURE SPRINTS - Systematic Restoration
2021

example/fortran/pcolormesh_demo/pcolormesh_demo.f90

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,33 @@ program pcolormesh_demo
1212
contains
1313

1414
subroutine demo_basic_gradient()
15-
!! Basic pcolormesh with simple gradient
16-
real(wp) :: x(6), y(5)
17-
real(wp) :: c(4, 5)
15+
!! Basic pcolormesh with simple gradient - enhanced 51x51 grid
16+
real(wp) :: x(51), y(51)
17+
real(wp) :: c(50, 50)
1818
integer :: i, j
19+
real(wp) :: dx, dy
1920

20-
! Create coordinate arrays for regular grid
21-
do i = 1, 6
22-
x(i) = real(i-1, wp) * 0.4_wp
21+
! Create coordinate arrays for high-resolution regular grid
22+
dx = 2.0_wp / 50.0_wp ! Total range 2.0, 50 intervals
23+
dy = 1.2_wp / 50.0_wp ! Total range 1.2, 50 intervals
24+
25+
do i = 1, 51
26+
x(i) = real(i-1, wp) * dx
2327
end do
24-
do i = 1, 5
25-
y(i) = real(i-1, wp) * 0.3_wp
28+
do i = 1, 51
29+
y(i) = real(i-1, wp) * dy
2630
end do
2731

28-
! Create test data - simple gradient
29-
do i = 1, 4
30-
do j = 1, 5
31-
c(i, j) = real(i, wp) + real(j, wp) * 0.5_wp
32+
! Create test data - smooth gradient across high-res grid
33+
do i = 1, 50
34+
do j = 1, 50
35+
c(i, j) = real(i, wp) / 50.0_wp + real(j, wp) / 50.0_wp * 0.5_wp
3236
end do
3337
end do
3438

3539
! Create pcolormesh plot
3640
call figure(figsize=[6.4_wp, 4.8_wp])
37-
call title('Basic Pcolormesh - Linear Gradient')
41+
call title('Basic Pcolormesh - Linear Gradient (50x50 resolution)')
3842
call xlabel('X coordinate')
3943
call ylabel('Y coordinate')
4044
call pcolormesh(x, y, c, colormap='viridis')
@@ -45,32 +49,36 @@ subroutine demo_basic_gradient()
4549
end subroutine demo_basic_gradient
4650

4751
subroutine demo_sinusoidal_pattern()
48-
!! Pcolormesh with sinusoidal pattern
49-
real(wp) :: x(9), y(9)
50-
real(wp) :: c(8, 8)
52+
!! Pcolormesh with sinusoidal pattern - enhanced 51x51 grid
53+
real(wp) :: x(51), y(51)
54+
real(wp) :: c(50, 50)
5155
real(wp) :: xi, yj
5256
integer :: i, j
5357
real(wp), parameter :: pi = 3.14159265359_wp
58+
real(wp) :: dx, dy
59+
60+
! Create coordinate arrays for high-resolution grid
61+
dx = 1.6_wp / 50.0_wp ! Total range 1.6, 50 intervals
62+
dy = 1.2_wp / 50.0_wp ! Total range 1.2, 50 intervals
5463

55-
! Create coordinate arrays
56-
do i = 1, 9
57-
x(i) = real(i-1, wp) * 0.2_wp
64+
do i = 1, 51
65+
x(i) = real(i-1, wp) * dx
5866
end do
59-
do i = 1, 9
60-
y(i) = real(i-1, wp) * 0.15_wp
67+
do i = 1, 51
68+
y(i) = real(i-1, wp) * dy
6169
end do
6270

63-
! Create sinusoidal pattern
64-
do i = 1, 8
65-
do j = 1, 8
66-
xi = (x(i) + x(i+1)) * 0.5_wp ! Center of quad
67-
yj = (y(j) + y(j+1)) * 0.5_wp ! Center of quad
71+
! Create sinusoidal pattern with proper sampling
72+
do i = 1, 50
73+
do j = 1, 50
74+
xi = (x(i) + x(i+1)) * 0.5_wp ! Center of cell
75+
yj = (y(j) + y(j+1)) * 0.5_wp ! Center of cell
6876
c(i, j) = sin(2.0_wp * pi * xi) * cos(3.0_wp * pi * yj)
6977
end do
7078
end do
7179

7280
call figure(figsize=[6.4_wp, 4.8_wp])
73-
call title('Pcolormesh - Sinusoidal Pattern')
81+
call title('Pcolormesh - Sinusoidal Pattern (50x50 resolution)')
7482
call xlabel('X coordinate')
7583
call ylabel('Y coordinate')
7684
call pcolormesh(x, y, c, colormap='coolwarm')
@@ -81,31 +89,37 @@ subroutine demo_sinusoidal_pattern()
8189
end subroutine demo_sinusoidal_pattern
8290

8391
subroutine demo_different_colormaps()
84-
!! Demo different colormaps
85-
real(wp) :: x(6), y(6)
86-
real(wp) :: c(5, 5)
87-
real(wp) :: r
92+
!! Demo different colormaps - enhanced 51x51 grid
93+
real(wp) :: x(51), y(51)
94+
real(wp) :: c(50, 50)
95+
real(wp) :: r, xi, yj
8896
integer :: i, j
8997
real(wp), parameter :: pi = 3.14159265359_wp
98+
real(wp) :: dx, dy
99+
100+
! Create coordinate arrays for high-resolution grid
101+
dx = 1.5_wp / 50.0_wp ! Total range 1.5, 50 intervals
102+
dy = 1.25_wp / 50.0_wp ! Total range 1.25, 50 intervals
90103

91-
! Create coordinate arrays
92-
do i = 1, 6
93-
x(i) = real(i-1, wp) * 0.3_wp
104+
do i = 1, 51
105+
x(i) = real(i-1, wp) * dx
94106
end do
95-
do i = 1, 6
96-
y(i) = real(i-1, wp) * 0.25_wp
107+
do i = 1, 51
108+
y(i) = real(i-1, wp) * dy
97109
end do
98110

99-
! Create radial pattern
100-
do i = 1, 5
101-
do j = 1, 5
102-
r = sqrt((x(i) - 1.0_wp)**2 + (y(j) - 0.6_wp)**2)
111+
! Create radial pattern with proper sampling
112+
do i = 1, 50
113+
do j = 1, 50
114+
xi = (x(i) + x(i+1)) * 0.5_wp ! Center of cell
115+
yj = (y(j) + y(j+1)) * 0.5_wp ! Center of cell
116+
r = sqrt((xi - 0.75_wp)**2 + (yj - 0.625_wp)**2)
103117
c(i, j) = exp(-r)
104118
end do
105119
end do
106120

107121
call figure(figsize=[6.4_wp, 4.8_wp])
108-
call title('Pcolormesh - Radial Pattern (Plasma)')
122+
call title('Pcolormesh - Radial Pattern (Plasma) (50x50 resolution)')
109123
call xlabel('X coordinate')
110124
call ylabel('Y coordinate')
111125
call pcolormesh(x, y, c, colormap='plasma')

src/fortplot_matplotlib.f90

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,22 @@ subroutine pcolormesh(x, y, z, shading, colormap, show_colorbar, label, &
156156
wp_linewidths = real(linewidths, wp)
157157
end if
158158

159-
! Forward SUPPORTED parameters to underlying method using single call pattern
160-
call fig%add_pcolormesh(wp_x, wp_y, wp_z, &
161-
colormap=merge(colormap, "", present(colormap)), &
162-
vmin=merge(wp_vmin, 0.0_wp, present(vmin)), &
163-
vmax=merge(wp_vmax, 0.0_wp, present(vmax)), &
164-
edgecolors=merge(wp_edgecolors, [0.0_wp, 0.0_wp, 0.0_wp], present(edgecolors)), &
165-
linewidths=merge(wp_linewidths, 0.0_wp, present(linewidths)))
159+
! Forward SUPPORTED parameters to underlying method using conditional calls
160+
if (present(colormap) .and. present(vmin) .and. present(vmax) .and. &
161+
present(edgecolors) .and. present(linewidths)) then
162+
call fig%add_pcolormesh(wp_x, wp_y, wp_z, &
163+
colormap=colormap, vmin=wp_vmin, vmax=wp_vmax, &
164+
edgecolors=wp_edgecolors, linewidths=wp_linewidths)
165+
else if (present(colormap) .and. present(vmin) .and. present(vmax)) then
166+
call fig%add_pcolormesh(wp_x, wp_y, wp_z, &
167+
colormap=colormap, vmin=wp_vmin, vmax=wp_vmax)
168+
else if (present(colormap)) then
169+
call fig%add_pcolormesh(wp_x, wp_y, wp_z, colormap=colormap)
170+
else if (present(vmin) .and. present(vmax)) then
171+
call fig%add_pcolormesh(wp_x, wp_y, wp_z, vmin=wp_vmin, vmax=wp_vmax)
172+
else
173+
call fig%add_pcolormesh(wp_x, wp_y, wp_z)
174+
end if
166175

167176
deallocate(wp_x, wp_y, wp_z)
168177
end subroutine pcolormesh
@@ -472,13 +481,22 @@ subroutine add_pcolormesh(x, y, z, shading, colormap, show_colorbar, label, &
472481
wp_linewidths = real(linewidths, wp)
473482
end if
474483

475-
! Forward SUPPORTED parameters to underlying method using single call pattern
476-
call fig%add_pcolormesh(wp_x, wp_y, wp_z, &
477-
colormap=merge(colormap, "", present(colormap)), &
478-
vmin=merge(wp_vmin, 0.0_wp, present(vmin)), &
479-
vmax=merge(wp_vmax, 0.0_wp, present(vmax)), &
480-
edgecolors=merge(wp_edgecolors, [0.0_wp, 0.0_wp, 0.0_wp], present(edgecolors)), &
481-
linewidths=merge(wp_linewidths, 0.0_wp, present(linewidths)))
484+
! Forward SUPPORTED parameters to underlying method using conditional calls
485+
if (present(colormap) .and. present(vmin) .and. present(vmax) .and. &
486+
present(edgecolors) .and. present(linewidths)) then
487+
call fig%add_pcolormesh(wp_x, wp_y, wp_z, &
488+
colormap=colormap, vmin=wp_vmin, vmax=wp_vmax, &
489+
edgecolors=wp_edgecolors, linewidths=wp_linewidths)
490+
else if (present(colormap) .and. present(vmin) .and. present(vmax)) then
491+
call fig%add_pcolormesh(wp_x, wp_y, wp_z, &
492+
colormap=colormap, vmin=wp_vmin, vmax=wp_vmax)
493+
else if (present(colormap)) then
494+
call fig%add_pcolormesh(wp_x, wp_y, wp_z, colormap=colormap)
495+
else if (present(vmin) .and. present(vmax)) then
496+
call fig%add_pcolormesh(wp_x, wp_y, wp_z, vmin=wp_vmin, vmax=wp_vmax)
497+
else
498+
call fig%add_pcolormesh(wp_x, wp_y, wp_z)
499+
end if
482500

483501
deallocate(wp_x, wp_y, wp_z)
484502
end subroutine add_pcolormesh

0 commit comments

Comments
 (0)