👉 Explore All My Excel Solutions: https://pythonandvba.com/solutions
𝗗𝗘𝗦𝗖𝗥𝗜𝗣𝗧𝗜𝗢𝗡
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
In this tutorial I will show you, how to create an animated Bar Chart, also known as a Barrace, in Python & Excel by using the library called Plotly.
The data is coming directly from an excel file.
You can do all the changes in the excel file and after running the script again you will have your updated Bar Chart Animation.
The Barrace is also interactive. If you hover over the bars, you will see additional information.
Lastly, the animation will be also saved as an HTML file. Hence, you could also send the animation to your friends & colleagues, who do not even need to have Python installed on their machines.
This tutorial is focusing on beginners in Python. Even you have never written a single line of code in Python, you will be able to have your free animated bar chart by the end of this tutorial.
👉 You can download the code & excel files for FREE here:
https://bit.ly/3kdNbzm
👩💻 𝗦𝗢𝗨𝗥𝗖𝗘 𝗖𝗢𝗗𝗘:
import plotly.express as px
import pandas as pd
import streamlit as st
import plotly
Read Data From Excel and store in a variable df [dataframe]
df = pd.read_excel("data.xlsx", usecols="A:C")
df.dropna(inplace=True)
Store each column in a seperate varibale.
country = df["Country"]
sales = df["Sales"]
date = df["Date"].dt.strftime("%Y-%m-%d")
Create Animated Bar Chart and store figure as fig
fig = px.bar(
df,
x=country,
y=sales,
color=country,
animation_frame=date,
animation_group=country,
range_y=[0, 1200],
)
Save Chart and export to HTML
plotly.offline.plot(fig, filename="Barrace.html")
𝗧𝗢𝗢𝗟𝗦 𝗔𝗡𝗗 𝗥𝗘𝗦𝗢𝗨𝗥𝗖𝗘𝗦
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🆓【𝗙𝗥𝗘𝗘】Excel Add-in (𝗠𝘆𝗧𝗼𝗼𝗹𝗕𝗲𝗹𝘁): https://pythonandvba.com/mytoolbelt
📊 Dashboard Excel Add-In (𝗚𝗿𝗮𝗳𝗹𝘆): https://pythonandvba.com/grafly
🎨 Cartoon Charts Excel Add-In (𝗖𝘂𝘁𝗲𝗣𝗹𝗼𝘁𝘀): https://pythonandvba.com/cuteplots
🤪 Fun Emoji Excel Add-In (𝗘𝗺𝗼𝗷𝗶𝗳𝘆): https://pythonandvba.com/emojify
📑 Excel Templates: https://pythonandvba.com/go/excel-tem...
🎓 My Courses: https://pythonandvba.com/go/courses
📚 Books, Tools, and More: https://pythonandvba.com/resources
𝗖𝗢𝗡𝗡𝗘𝗖𝗧 𝗪𝗜𝗧𝗛 𝗠𝗘
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🔗 LinkedIn: / sven-bosau
📸 Instagram: / codingisfun_official
💻 GitHub: https://github.com/Sven-Bo
💬 Discord: https://pythonandvba.com/discord
📬 Contact: https://pythonandvba.com/contact
☕ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲?
If you want to support this channel, you can buy me a coffee here: https://pythonandvba.com/coffee-donation