Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Python Kyoto Dash Returns

F3eb7cf23caf810b30aa798e335039d0?s=47 Hide Ogawa
January 18, 2019

Python Kyoto Dash Returns

Presentation / how to use dash plotly.
github: https://github.com/hannari-python/dash-handson
HannariPython is Kyoto's python community.
come and join us!

F3eb7cf23caf810b30aa798e335039d0?s=128

Hide Ogawa

January 18, 2019
Tweet

Transcript

  1. ͸ΜͳΓ1ZUIPOͷձ %BTI3FUVSOT ߹ಉձࣾɹ௕໨ খ઒ɹӳ޾

  2. %BTIͱ͸ʁʁ ɾ3FBDU 1MPUMZKT 'MBTLΛ࢖ͬͨՄࢹԽ ϥΠϒϥϦ ɾ1MPUMZͷ͓͔͛ͰΠϯλϥΫςΟϒͳ ՄࢹԽ͕ग़དྷΔɻ ɾ΢Σϒʹ؆୯ʹ͋͛ΒΕΔɻ IUUQTQZPTBLBIFSPLVBQQDPN

  3. ࢖͍ํ ɾυΩϡϝϯτʹৄ͘͠ॻ͔Ε͍ͯΔ IUUQTEBTIQMPUMZɹ ɾલճͷࢿྉΛ࢖͍ͳ͕Β ղઆ͠·͢ɻ IUUQTHJUIVCDPNIBOOBSJQZUIPOEBTIIBOETPO

  4. BQQQZ ίʔυ͸ IUUQTHJUIVCDPNIBOOBSJQZUIPOEBTI IBOETPOCMPCNBTUFSBQQQZ QZUIPOBQQQZ Ͱ࣮ߦͰ͖ΔɻIUUQ ͰɺͲͷΑ͏ʹಈ͍͍ͯΔ͔ݟΒΕΔɻ

  5. BQQQZ ϥΠϒϥϦͷΠϯϙʔτͷͱ͜Ζͷղઆ JNQPSUEBTI ࠷ॳʹΦϒδΣΫτΛ࡞Δͱ͜ΖͰ࢖͏ ͋ͱ͔ΒݟΔίʔϧόοΫͰ࢖͏ JNQPSUEBTI@DPSF@DPNQPOFOUTBTEDD ཁૉΛબͿεϥΠμʔ΍νΣοΫϘοΫεͳͲ άϥϑΛΠϯλϥΫςΟϒʹ͢Δ෦෼Ͱ࢖͏ άϥϑΛඳ͘ɺλϒΛ࢖͏ͳͲ͍Ζ͍Ζಓ۩͕͋Δ IUUQTEBTIQMPUMZEBTIDPSFDPNQPOFOUT

    JNQPSUEBTI@IUNM@DPNQPOFOUTBTIUNM IUNMͳίϯϙʔωϯτΛ࡞Δɻ %JWͱ͔)ͱ͔ɺҰจࣈ໨͕͍͍ͩͨେจࣈʹͳ͍ͬͯΔ .BSLEPXOͰ΋هड़Ͱ͖Δ IUUQTEBTIQMPUMZEBTIIUNMDPNQPOFOUT
  6. BQQQZ ࠷ޙͷ BQQSVO@TFSWFS EFCVH5SVF  ʹ͢Δͱɺ૸Βͤͳ͕Β಺༰Λมߋ͢Δ͜ͱ͕ग़དྷΔ άϥϑʹಸྑΛ෇͚Ճ͑ͯΈ·͢ɻ ͦͷଞϨΠΞ΢τͳͲΛ࢖ͬͯɺ ৭ʑͱ࿔͘Ε·͢ɻ 4FFBQQQZ

  7. BQQQZ ςʔϒϧͷදࣔɻؔ਺Λ࡞ͬͯදࣔͤ͞Δɻ ʹʹʼɹ݄ʹ%BTI%BUB5BCMF͕ϦϦʔε͞Εͨɻ લճ͸ग़ͨ௚ޙͩͬͨͷͰѻ͑ͣɾɾ JNQPSUEBTI@UBCMF IUUQTEBTIQMPUMZEBUBUBCMF BQQQZ BQQQZͱBQQQZ͸΄΅ಉ͜͡ͱΛ΍ͬͯΔɻ EBTI@UBCMFΛ࢖͑͹؆୯ɻ ͜ΕʹίʔϧόοΫΛ࢖͏ͱɺ΋ͬͱ৭ʑग़དྷΔʂ

  8. BQQQZ ίʔϧόοΫΛ࢖͍࢝ΊΔʂ ίʔϧόοΫ͕ͳͯ͘΋͖Ε͍Ͱྑ͍͚Ͳɺ ίʔϧόοΫΛ࢖͏͜ͱʹΑΓɺ άϥϑ͕ΠϯλϥΫςΟϒʹͳΓɺڻ͘Α͏ͳ σʔλͷັͤํ͕ग़དྷΔʂ !BQQDBMMCBDL  EBTIEFQFOEFODJFT0VUQVU lPVUQVUJEz

    lpHVSFz  <EBTIEFQFOEFODJFT*OQVU lJOQVUJEz lWBMVFz >  EFGNBLF@HSBQI POF@WBMVFT  ddd
  9. BQQQZ ͜͜Ͱ͸εϥΠμʔͰબ୒ͨ͠೥Λ EBTIEFQFOEFODJFT*OQVUͰεϥΠμʔͷ*%Λ ࢦఆ͠ɺ஋Λؔ਺಺ʹಡΈࠐΈͦͷ஋ͰσʔλΛ Ճ޻͠ɺάϥϑΛ EBTIEFQFOEFODJFT0VUQVUͰࢦఆͨ͠*% ʹฦ͢ͱ͍͏࡞ۀ͕ߦΘΕ͍ͯ·͢ɻ ͜ΕΛߦ͏͜ͱʹΑΓɺεϥΠμʔͷ஋Λಈ͔͢͝ͱʹ σʔλͷ೥౓͕มΘΓɺάϥϑ͕มԽ͠·͢ɻ

  10. BQQQZ BQQQZ͸υϩοϓμ΢ϯΛͭ෇͚σʔλΛ બ୒Ͱ͖ΔΑ͏ʹ͠ɺϨσΟΦΞΠςϜͰ ࣮਺͔MPH͔Λબ୒Ͱ͖ΔΑ͏ʹ͍ͯ͠·͢ɻ ͦͯ͠άϥϑ͸ͭ͋Γ·͢ɻ ࠨଆͰશମσʔλΛදࣔ͠·͢ɻ ͜ͷԼͷεϥΠμʔͰࠨଆʹάϥϑͰදࣔ͢Δ ೥Λબͼ·͢ɻ ͦͯ͠ɺӈଆͷͭͰࠨଆͷάϥϑΛϚ΢εͰϗόʔͨ͠ ࠃͷσʔλͷώετϦΧϧΛදࣔ͠·͢ɻ

  11. BQQQZ ͜ͷྫͰ͸ίʔϧόοΫ͸ͭ͋Γ·͢ɻ ̍ɽࠨଆͷάϥϑ͸υϩοϓμ΢ϯͰදࣔཁૉ͕มԽ͢Δ ·ͨɺεϥΠμʔͷมԽͱͱ΋ʹදࣔ೥͕มΘΔ ɹϗόʔσʔλ͔ΒࠃσʔλΛऔಘ͠ɺཁૉʹؔͯ͠ ࠃͷώετϦΧϧσʔλΛͭ͘ΓάϥϑԽ͢Δ ɹɹɹɹɹɹɹɹɹɹɹɹɹɹ country_name = hoverData['points'][0]['customdata']

    ɹ্Λ্ԼͷάϥϑͰ΍Δ
  12. BQQQZ IPWFSEBUBͷҋ νϣοτͪΌΜͱॻ͍͍ͯΔ΋ͷ͕ͳ͍͔Β ղΓʹ͍͘ɾɾɾ ώϯτɿIUUQTEBTIQMPUMZJOUFSBDUJWFHSBQIJOH ͭ໨ͷάϥϑ The dcc.Graph component has

    four attributes that can change through user- interaction: hoverData, clickData, selectedData, relayoutData. These properties update when you hover over points, click on points, or select regions of points in a graph.
  13. ͻͱ·ͣ ऴྃ