Hey, I’ve coded a discord bot that tracks users presence (status) and want to graph it as a horizontal bar chart.
I have the data in this format:
The first column has the names of the servers members.
Second column is an array with the lengths (in seconds) and status’
I coded this in matplotlib so it looks like this:
How would I go about replicating this in plotly? The way it’s coded using matplotlib I am using for loops to loop through the data and add a new bar with the relevant width, x-position, y-position and color. Here’s the code that does that:
colors = {“dnd”: “red”,
“online”: “lime”,
“online(Mobile)”: “green”,
“offline”: “gray”,
“idle”: “yellow”,
“dnd(Mobile)”: “red”
}
fig = plt.figure(figsize=(18,6))
ax = fig.add_subplot(111)
for members in log_data: #
left = 0
for status in members[1]: # (172, "online")
width = status[0] # 172
label = status[1] # "online"
y = members[0] # member name (y-position)
ax.barh(y, width, align='center', height=0.8, left=left, color=colors[label],label=label)
left += width
What I’ve been looking for in plotty is the “left” parameter. Or another way to do it, but I haven’t figured it out.