Problem with radialaxis ticks in polar plot when using date values
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 18.8k
- Fork
- 2.8k
- Merge trung bình
- 16 giờ 26 phút
- Pull request đã merge (30 ngày)
- 21
Mô tả
Hello, I managed to create a polar heatmap plot following the examples given in #2024, but when trying to use time as the radial dimension I found some problems with the ticks. I tried with tickmodes auto, linear and array but got wrong ticks with all of them. The time values shown in the hover are correct, only the ticks appear to be wrong. Does anyone have a suggestion on what may be the problem?
Thank you.
import numpy as np
import pandas as pd
import plotly.graph_objects as go
from plotly.offline import plot
from datetime import datetime, timedelta
# dt_start, dt_end, dt_step ='2000-01-01', '2001-01-01', '1MS'
dt_start, dt_end, dt_step ='2000-01-01', '2000-01-10', '1D'
times = pd.date_range(dt_start, dt_end, freq=dt_step).values
dirs = np.arange(180, 271, 10)
r, theta = np.meshgrid(times, dirs)
z = np.random.random(r.shape)
hovertemplate = (f'date: %{{r|%Y-%m-%d %H:%M:%SZ}}<br>'
f'direction: %{{theta}}<br>'
f'value: %{{customdata[0]:.2f}}'
'<extra></extra>')
fig = go.Figure(go.Barpolar(r=r.ravel(),
theta=theta.ravel(),
marker_color=z.ravel(),
customdata=np.expand_dims(z.ravel(), 0).T,
hovertemplate=hovertemplate))
fig.update_layout(polar=dict(
angularaxis=dict(tickvals=np.arange(0, 360, 45),
direction='clockwise'),
radialaxis=dict(angle=45,
tickangle=45,
tickfont={'size': 14},
tickformat='%Y-%m-%d %H:%M:%S',
# tickmode='auto',
# nticks=5,
# tickmode='linear',
# tick0=times[0],
# dtick='1D',
tickmode='array',
tickvals=times,
)))
fig.show()
With tickmode='auto':

With tickmode='linear':

With tickmode='array':

Using plotly.version = '5.4.0'
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách chạy ví dụ Python được cung cấp với Plotly 5.4.0 và so sánh các vạch đánh dấu trên trục hướng tâm được tạo ra bởi các chế độ auto, linear và array. Theo dõi việc xử lý vạch đánh dấu trên trục hướng tâm đối với dữ liệu r có giá trị ngày tháng. Hoàn thành khi cả ba chế độ được hỗ trợ đều tạo ra các vạch đánh dấu ngày tháng được định vị và định dạng chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100