Skip to content

[Bug] Analemma polar plot hour_labels=true seems unstable if not exacly hourly. #44

@RobbesU

Description

@RobbesU

Description

Hi @langestefan Thanks for an amazing package. Fab !

Probably more of a upgrade request than a real bug, as it doesn't truly 'break'.
Just playing with the PolarPlot plot example.
Works perfect for the (intended?) one-hours plot intervals, but output goes odd when plotting other intervals, either longer or shorter with hour_labels=true).
E.g. plotting only every two hours the not-available hour label is put in the middle of the next analemma (I learned a new word today), and plotting every 30mins it shifts the hour labels.

Image Image

Package Version

0.3.1

Julia Version

12.3

Reproduction steps

obs = Observer(51.47800, -0.00153, 72.0)  # London Greenwich
timezone = TimeZone("Europe/London")
time_year = 2025
time_interval = Minute(120)   # use 30,60,120 for the respective plots
times = ZonedDateTime.( collect(DateTime(time_year,1,1):time_interval:DateTime(time_year+1,1,1)-time_interval), timezone, from_utc=true)

positions = solar_position(obs, times)
df = DataFrame(positions)
df.datetime = times

fig = Figure(size=(600,600)) 
ax = PolarAxis(fig[1,1], title = "Greenwich Sun Positions 2025") 

sunpathpolarplot!(ax, df, hour_labels=true)

# same result as example, but refactored for single source input for all data
lines_months = [3,6,12]
lines_day = 21
dates = [Date(time_year,m,lines_day) for m in lines_months]  # 21/3,21/6, 21/12 for 2025
labels = Dates.format.(dates, "dd-u")        # labels as "21-Mar"
date_colors = [:purple, :black, :grey, :]

line_objects = []
for (i, (date, label)) in enumerate(zip(dates, labels))
	day_df = filter(:datetime => t -> Date(t)==date, df)
	day_filtered = day_df[day_df.elevation.>0, :]
	line_obj = lines!(ax, deg2rad.(day_filtered.azimuth), day_filtered.zenith, linewidth=2, label=label, color=date_colors[i])
	push!(line_objects, line_obj)


fig[2,1] = Legend(fig, line_objects, labels, orientation=:horizontal)
	
fig

Relevant log output

Status `C:\Users\...\Project.toml`
  [a93c6f00] DataFrames v1.8.1
  [e9467ef8] GLMakie v0.13.8
  [67456a42] OhMyThreads v0.8.3
  [7f904dfe] PlutoUI v0.7.76
  [5b9d1343] SolarPosition v0.3.1
  [f269a46b] TimeZones v1.22.2
  [ade2ca70] Dates v1.11.0
  [37e2e46d] LinearAlgebra v1.12.0

Operating System

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions