Skip to content

Commit da6ae79

Browse files
committed
Refactor ROIVisualization.jl inclusion and update scalebar function in MakieRecipes.jl
- Commented out the inclusion and export of functions from ROIVisualization.jl to streamline the initialization process. - Enhanced the scalebar function by adding pixel offset parameters for better text positioning and improved label formatting, ensuring clarity in visualizations.
1 parent 6e74a2d commit da6ae79

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/PhysMakie/MakieRecipes.jl

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ end
293293
# Export the function
294294
export stimulustiming!
295295

296+
@info "MakieRecipes.jl loaded at $(time())"
296297
"""
297298
scalebar!(ax; origin=(0.0, 0.0), length_x=nothing, length_y=nothing,
298299
color=:black, linewidth=2.0, text_color=:black, fontsize=12,
@@ -336,8 +337,9 @@ function scalebar!(ax;
336337
fontsize = 12,
337338
xlabel = nothing,
338339
ylabel = nothing,
339-
offset_x_ratio = 10.0,
340-
offset_y_ratio = 0.2
340+
xlabel_addon = "ms", ylabel_addon = "dff",
341+
pixel_offset_x = 20, # Distance in pixels from scale bar
342+
pixel_offset_y = 20 # Distance in pixels from scale bar
341343
)
342344
x_start, y_start = origin
343345

@@ -350,12 +352,15 @@ function scalebar!(ax;
350352
linewidth = linewidth
351353
)
352354

353-
x_label_text = isnothing(xlabel) ? "$(length_x)" : xlabel
355+
x_label_text = isnothing(xlabel) ? "$(length_x)$xlabel_addon" : "$xlabel$xlabel_addon"
356+
357+
# Use pixel coordinates for text positioning
354358
text!(ax, x_label_text,
355-
position = (x_start + length_x/2, y_start - y_start/offset_x_ratio),
356-
align = (:center, :center),
359+
position = (x_start + length_x/2, y_start), # Center horizontally on scale bar
360+
align = (:center, :center), # Align to top so we can offset downward
357361
color = text_color,
358-
fontsize = fontsize
362+
fontsize = fontsize,
363+
offset = (0, -pixel_offset_y) # Offset downward by pixel_offset_y pixels
359364
)
360365
end
361366

@@ -368,13 +373,16 @@ function scalebar!(ax;
368373
linewidth = linewidth
369374
)
370375

371-
y_label_text = isnothing(ylabel) ? "$(length_y)" : ylabel
376+
y_label_text = isnothing(ylabel) ? "$(length_y)$ylabel_addon" : "$ylabel$ylabel_addon"
377+
378+
# Use pixel coordinates for text positioning
372379
text!(ax, y_label_text,
373-
position = (x_start - x_start/offset_y_ratio, y_start + length_y/2),
374-
align = (:center, :center),
380+
position = (x_start, y_start + length_y/2), # Center vertically on scale bar
381+
align = (:center, :center), # Align to right so we can offset leftward
375382
color = text_color,
376383
fontsize = fontsize,
377-
rotation = pi/2 # Makie uses radians for rotation
384+
rotation = pi/2, # Makie uses radians for rotation
385+
offset = (-pixel_offset_x, 0) # Offset leftward by pixel_offset_x pixels
378386
)
379387
end
380388

src/PhysiologyPlotting.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function __init__()
2828
@require PhysiologyAnalysis = "123dc426-2d49-4783-ab3e-573ab3c498a8" begin
2929
using .PhysiologyAnalysis
3030
import .PhysiologyAnalysis: get_fit_parameters, get_significant_rois
31-
include("PlottingFunctions/ROIVisualization.jl")
32-
export plot_roi_analysis, plot_roi_analysis_averaged, plot_roi_analysis_stitched, plot_analysis, plot_fulltime_analysis, get_significant_traces, get_significant_traces_matrix
31+
# include("PlottingFunctions/ROIVisualization.jl")
32+
# export plot_roi_analysis, plot_roi_analysis_averaged, plot_roi_analysis_stitched, plot_analysis, plot_fulltime_analysis, get_significant_traces, get_significant_traces_matrix
3333
end
3434
end
3535

@@ -51,8 +51,8 @@ function __init__()
5151
using .PhysiologyAnalysis
5252
import .PhysiologyAnalysis: get_fit_parameters, get_significant_rois
5353
import .PhysiologyAnalysis: baseline_trace
54-
include("PlottingFunctions/ROIVisualization.jl")
55-
export plot_roi_analysis
54+
# include("PlottingFunctions/ROIVisualization.jl")
55+
# export plot_roi_analysis
5656
end
5757
end
5858

0 commit comments

Comments
 (0)