@@ -126,8 +126,8 @@ subroutine compute_symlog_ticks(data_min, data_max, threshold, tick_positions, n
126126 call add_negative_symlog_ticks(data_min, - threshold, tick_positions, num_ticks)
127127 end if
128128
129- ! Add linear region ticks
130- if (data_min <= threshold .and. data_max > = - threshold) then
129+ ! Add linear region ticks (only for the region within threshold bounds)
130+ if (max ( data_min, - threshold) <= min ( data_max, threshold) ) then
131131 call add_linear_symlog_ticks(max (data_min, - threshold), min (data_max, threshold), &
132132 tick_positions, num_ticks)
133133 end if
@@ -200,39 +200,102 @@ function calculate_nice_step(raw_step) result(nice_step)
200200 end function calculate_nice_step
201201
202202 subroutine add_negative_symlog_ticks (data_min , upper_bound , tick_positions , num_ticks )
203+ ! ! Add ticks for negative logarithmic region of symlog scale
203204 real (wp), intent (in ) :: data_min, upper_bound
204205 real (wp), intent (inout ) :: tick_positions(MAX_TICKS)
205206 integer , intent (inout ) :: num_ticks
206207
207- ! Suppress unused parameter warnings for stub implementation
208- associate(unused_real = > data_min + upper_bound, &
209- unused_arr = > tick_positions, unused_int = > num_ticks); end associate
208+ real (wp) :: log_min, log_max, current_power
209+ integer :: start_power, end_power, power
210+
211+ if (data_min >= 0.0_wp .or. upper_bound >= 0.0_wp .or. upper_bound <= data_min) return
212+
213+ ! Work with positive values for log calculations
214+ ! For negative range [-500, -1], we want powers that give us ticks in that range
215+ log_min = log10 (- upper_bound) ! log10(1) = 0 (closer to zero)
216+ log_max = log10 (- data_min) ! log10(500) = ~2.7 (larger magnitude)
217+
218+ start_power = floor (log_min)
219+ end_power = ceiling (log_max)
210220
211- ! Implementation for negative symlog region (placeholder)
221+ do power = start_power, end_power
222+ if (num_ticks >= MAX_TICKS) exit
223+ current_power = - (10.0_wp ** power)
224+
225+ ! Check if tick is within bounds, excluding threshold boundary
226+ if (current_power >= data_min - 1.0e-10_wp .and. &
227+ current_power < upper_bound - 1.0e-10_wp ) then
228+ num_ticks = num_ticks + 1
229+ tick_positions(num_ticks) = current_power
230+ end if
231+ end do
212232 end subroutine add_negative_symlog_ticks
213233
214234 subroutine add_linear_symlog_ticks (lower_bound , upper_bound , tick_positions , num_ticks )
235+ ! ! Add ticks for linear region of symlog scale
215236 real (wp), intent (in ) :: lower_bound, upper_bound
216237 real (wp), intent (inout ) :: tick_positions(MAX_TICKS)
217238 integer , intent (inout ) :: num_ticks
218239
219- ! Suppress unused parameter warnings for stub implementation
220- associate(unused_real = > lower_bound + upper_bound, &
221- unused_arr = > tick_positions, unused_int = > num_ticks); end associate
240+ real (wp) :: range, step, tick_value
241+ integer :: max_linear_ticks, i
242+
243+ if (upper_bound <= lower_bound) return
244+
245+ range = upper_bound - lower_bound
246+ max_linear_ticks = 5 ! Reasonable number for linear region
247+
248+ ! Always include zero if it's in the range
249+ if (lower_bound <= 0.0_wp .and. upper_bound >= 0.0_wp .and. num_ticks < MAX_TICKS) then
250+ num_ticks = num_ticks + 1
251+ tick_positions(num_ticks) = 0.0_wp
252+ end if
253+
254+ ! Add additional linear ticks
255+ step = range / real (max_linear_ticks + 1 , wp)
256+ step = calculate_nice_step(step)
222257
223- ! Implementation for linear symlog region (placeholder)
258+ ! Find first tick >= lower_bound
259+ tick_value = ceiling (lower_bound / step) * step
260+
261+ do while (tick_value <= upper_bound .and. num_ticks < MAX_TICKS)
262+ ! Skip zero if already added, avoid duplicates
263+ if (abs (tick_value) > 1.0e-10_wp ) then
264+ num_ticks = num_ticks + 1
265+ tick_positions(num_ticks) = tick_value
266+ end if
267+ tick_value = tick_value + step
268+ end do
224269 end subroutine add_linear_symlog_ticks
225270
226271 subroutine add_positive_symlog_ticks (lower_bound , data_max , tick_positions , num_ticks )
272+ ! ! Add ticks for positive logarithmic region of symlog scale
227273 real (wp), intent (in ) :: lower_bound, data_max
228274 real (wp), intent (inout ) :: tick_positions(MAX_TICKS)
229275 integer , intent (inout ) :: num_ticks
230276
231- ! Suppress unused parameter warnings for stub implementation
232- associate(unused_real = > lower_bound + data_max, &
233- unused_arr = > tick_positions, unused_int = > num_ticks); end associate
277+ real (wp) :: log_min, log_max, current_power
278+ integer :: start_power, end_power, power
279+
280+ if (lower_bound <= 0.0_wp .or. data_max <= 0.0_wp ) return
234281
235- ! Implementation for positive symlog region (placeholder)
282+ log_min = log10 (lower_bound)
283+ log_max = log10 (data_max)
284+
285+ start_power = floor (log_min)
286+ end_power = ceiling (log_max)
287+
288+ do power = start_power, end_power
289+ if (num_ticks >= MAX_TICKS) exit
290+ current_power = 10.0_wp ** power
291+
292+ ! Check if tick is within bounds, excluding threshold boundary
293+ if (current_power > lower_bound + 1.0e-10_wp .and. &
294+ current_power <= data_max + 1.0e-10_wp ) then
295+ num_ticks = num_ticks + 1
296+ tick_positions(num_ticks) = current_power
297+ end if
298+ end do
236299 end subroutine add_positive_symlog_ticks
237300
238301 function is_power_of_ten (value ) result(is_power)
0 commit comments