बटनों से annotations बदलना
एक बड़े ई-कॉमर्स कंपनी के सेल्स विभाग ने आपसे अपने डेटा को समझने और विज़ुअलाइज़ करने में मदद मांगी है.
उन्होंने मासिक सेल्स डेटा दिया है, लेकिन मासिक प्रदर्शन को आँकने के लिए वे अलग-अलग मेट्रिक्स इस्तेमाल करते हैं: monthly sales value (डॉलर में) और sales volume (बेचे गए आइटम्स की संख्या).
वे यह सारा डेटा एक ही प्लॉट पर देखना चाहते हैं और चर्चा को आसान बनाने के लिए annotations को आसानी से ऑन/ऑफ टॉगल करना चाहते हैं.
इस अभ्यास में, आप बटनों की मदद से महत्वपूर्ण annotations को ऑन या ऑफ करके सेल्स विभाग को अपने सेल्स डेटा का विश्लेषण करने में सहायता करेंगे.
आपको एक sales DataFrame दिया गया है और आपके लिए एक go.Figure() ऑब्जेक्ट सेट किया जाएगा.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Plotly के साथ Data Visualization परिचय
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Create the figure
fig = Figure()
# Create and add traces (done for you)
fig.add_trace(px.bar(sales, x="Month", y="Sales Volume", color_discrete_sequence=['blue']).data[0])
fig.add_trace(px.bar(sales, x="Month", y="Sales Value", color_discrete_sequence=['red']).data[0])
# Create annotations
value_annotations=[{'text': 'Sept was the best', 'showarrow': True, 'x': '____', 'y': 345397}]
volume_annotations=[{'text': 'Oct was the best', 'showarrow': True, 'x': '____', 'y': 71900}]
# Create buttons
my_buttons = [
{'label': "By Sales Value", 'method': "update", 'args': [{}, {'____': ____}]},
{'label': "By Sales Volume", 'method': "update", 'args': [{}, {'____': ____}]}]