पोज़िशन के अनुसार फ्री-थ्रो प्रतिशत
एजेंसी ने आपसे एक अंतिम प्लॉट माँगा है। आप factor_cmap का उपयोग करके एक scatter plot बनाएँगे जो free throw प्रतिशत बनाम औसत पॉइंट्स दिखाएगा, और हर खिलाड़ी की पोज़िशन को अलग रंग में प्रदर्शित करेगा।
nba डेटासेट से बना source नाम का एक source ऑब्जेक्ट पहले से लोड किया गया है। वैरिएबल TOOLTIPS, जिसमें खिलाड़ी का नाम है, भी बनाया गया है ताकि प्लॉट पर माउस होवर करने पर वह दिखाई दे.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Bokeh के साथ इंटरएक्टिव डेटा विज़ुअलाइज़ेशन
अभ्यास निर्देश
Category10_5औरfactor_cmapइम्पोर्ट करें.positionsबनाएँ, जिसमें"PG","SG","SF","PF", और"C"हों.fig.circle()मेंlegend_fieldआर्ग्युमेंट को"position"दें औरfill_colorआर्ग्युमेंट को पूरा करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import modules
____
____
# Create positions
positions = ["____", "____", "____", "____", "____"]
fig = figure(x_axis_label="Free Throw Percentage", y_axis_label="Points", title="Free Throw Percentage vs. Average Points", tooltips=TOOLTIPS)
# Add circle glyphs
fig.circle(x="free_throw_perc", y="points", source=source, legend_field="____", fill_color=factor_cmap("____", palette=____, factors=____))
output_file(filename="average_points_vs_free_throw_percentage.html")
show(fig)