I'd like select the range on the angular axis at a Plotly polar plot, and I am wondering what's the easiest way to do it. Ideally, if I click-and-drag from 30 to 90 degree then I'd like to have the range from 30 to 90 degree; if I click-and-drag from 330 to 30 degree, then I'd like to have the range from 330 to 30 degree.
I don't know much about Plotly, but I wonder whether relayoutData is something that can be tapped into. Currently it only returns the range on the radial axis (see the range returned from relayoutData in pic). I wonder whether there is a parameter can be changed to make it to return the range of angular axis?
Here is the minimal code to generate the figure above
import json
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.express as px
import pandas as pd
app = dash.Dash(__name__)
df = px.data.wind()
fig = px.scatter_polar(df, r="frequency", theta="direction")
app.layout = html.Div([
dcc.Graph(
id='basic-interactions',
figure=fig
),
html.Div(className='row', children=[
html.Div([
dcc.Markdown("""
**Zoom and Relayout Data**
Click and drag on the graph to zoom or click on the zoom
buttons in the graph's menu bar.
Clicking on legend items will also fire
this event.
"""),
html.Pre(id='relayout-data'),
])
])
])
@app.callback(
Output('relayout-data', 'children'),
Input('basic-interactions', 'relayoutData'))
def display_relayout_data(relayoutData):
return json.dumps(relayoutData, indent=2)
if __name__ == '__main__':
app.run_server(debug=True)
